I am trying to create an elasticsearch query that must match one of the three queries in separate fields, and also have an additional query that is not required to match. The problem with executing bool requests and the MUST clause is that it must match all 3, and with SHOULD this not always match those that are required, unless minis_should_match is set to 2. In this case, it does not match the documents that match one of the three required due to minimal matching.
My current request is like this (sorry, I have no code here)
query
- bool
- must
- query 1
- query 2
- query 3
- should
- query 4
I also tried the following, but it does not make the 4th request optional
query
- bool
- should
- query 1
- query 2
- query 3
- query 4
- minimum_should_match: 2
How to do this and create a query that MUST match one of the three queries and, if desired, evaluate those with a fourth query higher.
source
share