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


(Jeremyasm) #1

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


(Chris Roberson) #2

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


(Jeremyasm) #3

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 ?


(Jeremyasm) #4

{
"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"


(Chris Roberson) #5

@jeremyasm Great, so all set?


(Jeremyasm) #6

@chrisronline
Yes.
Happy New Year !


(system) #7

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