I want to match documents satisfying all the conditions below:
- author == "tom"
- status != "deleted"
- at least two of
f1-f4
fields match given values
(all fields are keyword
)
{"size":24,
"query":{
"bool":{
"filter":[{"term":{"author":{"value":"tom","boost":1.0}}}],
"must_not":[{"term":{"status":{"value":"deleted","boost":1.0}}}],
"should":[
{"term":{"f1":{"value":"v1","boost":1.0}}},
{"term":{"f2":{"value":"v2","boost":1.0}}},
{"term":{"f3":{"value":"v3","boost":1.0}}},
{"term":{"f4":{"value":"v4","boost":1.0}}}
],
"minimum_should_match":"2",
"boost":1.0
}}
}
UPDATE & SUMMARY
The query I post above is in fact correct, but my es provider installed a buggy custom plugin performing "query optimization" which leads to all "minimum_should_match" ignored. If you encounter the same problem and can't find any clue, maybe you should check if you have any suspicious plugin installed