How to implement a "is not one of " filter by using Query DSL

Hi,

We'd like to implement a "is not one of " filter by using Query DSL because there're so many items in "is not one of" List.
And we want to reuse the filter in many other dashboards, so writing Query DSL would be much easier, otherwise we have to type the items again and again for each dashboards.

I tried to use "must_not", but error occured.

Thanks !

image

Hi @jeremyasm,

I might misunderstand your question, but you could query for something like:
doc.garage_name: (-Canada -Communications) and that should work. Then, you can save that as a saved search and build visualizations from that.

Does that help?

Thanks,
Chris

image

I'd like to edit an Elasticsearch Query DSL rather than a filter.

Could you please give me a sample of "is not one of" query ?

{
"query": {
"bool": {
"must_not": {
"terms": {
"doc.garage_name.keyword": [
"Canada",
"Communication",
"USA"
]
}
}
}
}
}

This is what I want, by using this Query DSL, I exclude docs of which the garage_name is "Canada", "USA", "Communication"

@jeremyasm Great, so all set?

@chrisronline
Yes.
Happy New Year !

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.