lucene DisjunctionMaxQuery


Example

This combines queries such that the best (that is, highest-scoring) match of it's subqueries contributes to the final score.

List<Query> disjuncts = new ArrayList<Query>();
disjuncts.add(new TermQuery(new Term("fieldname", "hello")));
disjuncts.add(new TermQuery(new Term("fieldname", "world")));
Query query = new DisjunctionMaxQuery(disjuncts, 0.0f);

The second argument to the DisjunctionMaxQuery constructor is a tiebreaker value, which, when non-zero, allows non-maximal matches to make some small contribution to score, in order to break ties. It should generally be small (on the order of 0.1).