Why minimun_should_match must not be lower than 1?

In the documentation of the minimum_should_match parameter of the bool query it is stated

... the minimum number of required matches will never be lower than 1 or greater than the number of clauses.

Why is this restriction enforced? What if I use the must part of bool for everything I really want and should for purely optional requirements. BTW, it is still possible to circumvent the restriction that minimum_should_match must be greater or equal than 1 if it is an integer by adding and additional should clause that fits just everything like:

{
    "constant_score": {
        "boost": 0,
        "filter": {
            "match_all": {}
         }
     }
},

So why not get completely rid of that by allowing "minimum_should_match": 0?

Hi,

If you are refering to the reference for Minimum Should Match, I think the statement only applies to cases where there is a calculation involved (e.g. percentages). You should be able to use "minimum_should_match" : 0 (which is equivalent to having no "minimum_should_match" restriction) and you will get all documents matching the requiered "must" clauses, with the ones where the "should" clauses match with a higher score.
Negative values also work as described in the reference mentioned above.

Hi,

thanks for your reply. You are right that it works if I set minimum_should_match to 0 but I wasn't sure what it was doing internally. If it is like you are saying and the statement about the minimum of 1 only applies in the case of calculations, it's exactly what I want.
Thanks.

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