I want to filter my results with two different clauses aggregated with OR e.g. return documents with PropertyA=true OR PropertyB=true.
I've been trying to do this using a bool query. My base query is just a text search in must . If I put both clauses in the filter occurrence type, it aggregates them with an AND. If I put both clauses in the should occurrence type with minimum_should_match set to 1, then I get the right results. But then, documents matching both conditions get a higher score because "should" runs in a query context.
How do I filter to only documents matching either of two conditions, without increasing the score of documents matching both conditions?
Look at the 3 posts following .. the first solution I put the OR in the query context , the 2nd I put the OR in the filter context... Which is what you are asking about.
Thank you this looks perfect! Any ideas how to do that in NEST? It looks like the Filter property on BoolQuery only takes an IEnumerable<QueryContainer>.
Edit Nevermind, got it right after I posted:
QueryContainer inner = new BoolQuery
{
Should = new[] {qc1, qc2},
MinimumShouldMatch = new MinimumShouldMatch(1)
};
var outer = new BoolQuery
{
MustNot = new[] {qc3, qc4},
Must = new[] {qc5},
Filter = new[] {inner}
};
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.