I have a "should" block in my bool query that contains 3 conditions. It would match anything that matches any 1 or more of the 3 conditions. But I would like to exclude anything that matches all 3 conditions, i.e. only match 1 or 2 of the conditions. Is there something like a maximum_should_match that would give me the equivalent of this?
You can also do the same with a bool query and a must_not clause containing a should clause. Like:
{
"query": {
"bool": {
"minimum_should_match": 1,
"should": [ your queries ],
"must_not": [
"bool": {
"minimum_should_match": 3, <---- this is your maximum_should_match
"should": [ your queries again ]
}
]
}
}
}
Its the same as your query_string way but keeps you in the DSL. Its not as good as having native maximum_should_match though because it has to evaluate the queries twice. But if it is fast enough then it is fast enough.
I got a parse error running this search in Kibana. I think the DSL doesn't allow you to embed another "bool" query inside any of the higher level "bool"'s subconditions... I did try some variation of that in my earlier attempts and that's what stopped me.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.