I am trying to create an elasticsearch query that has to match one of three queries on seperate fields and also have an extra query that is not a requirement to be matched. The problem with doing bool queries and the MUST clause is that it has to match all 3, and with the SHOULD it not always matches the ones that are required, except when using minimum_should_match set to 2. In that case, it doesnt match on documents that match one of the 3 required ones because of the minimum match.
My current query is like this (sorry, dont have the code right here)
query
- bool
- must
- query 1
- query 2
- query 3
- should
- query 4
I have also tried the following, but it doesnt make the 4th query optional
query
- bool
- should
- query 1
- query 2
- query 3
- query 4
- minimum_should_match: 2
How would one go about and create a query that MUST match one of three queries and optionally rank those with the 4th query higher.