A query that generates the union of documents produced by its subqueries, and that scores each document with the maximum score for that document as produced by any subquery, plus a tie breaking increment for any additional matching subqueries. This is useful when searching for a word in multiple fields with different boost factors (so that the fields cannot be combined equivalently into a single search field). We want the primary score to be the one associated with the highest boost, not the sum of the field scores (as BooleanQuery would give). If the query is "albino elephant" this ensures that "albino" matching one field and "elephant" matching another gets a higher score than "albino" matching both fields. To get this result, use both BooleanQuery and DisjunctionMaxQuery: for each term a DisjunctionMaxQuery searches for it in each field, while the set of these DisjunctionMaxQuery's is combined into a BooleanQuery. The tie breaker capability allows results that include the same term in multiple fields to be judged better than results that include this term in only the best of those multiple fields, without confusing this with the better case of two different terms in the multiple fields.

The DisjunctionMaxQuery..::..DisjunctionMaxWeight type exposes the following members.

Constructors

Methods

  NameDescription
Public methodEquals
Determines whether the specified Object is equal to the current Object.
(Inherited from Object.)
Public methodExplain (Overrides Weight..::..Explain(IndexReader, Int32).)
Protected methodFinalize
Allows an Object to attempt to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection.
(Inherited from Object.)
Public methodGetHashCode
Serves as a hash function for a particular type.
(Inherited from Object.)
Public methodGetQuery (Overrides Weight..::..GetQuery()()()().)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodGetValue (Overrides Weight..::..GetValue()()()().)
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Public methodNormalize (Overrides Weight..::..Normalize(Single).)
Public methodScorer (Overrides Weight..::..Scorer(IndexReader, Boolean, Boolean).)
Public methodScoresDocsOutOfOrder
Returns true iff this implementation scores docs only out of order. This method is used in conjunction with {@link Collector}'s {@link Collector#AcceptsDocsOutOfOrder() acceptsDocsOutOfOrder} and {@link #Scorer(Lucene.Net.Index.IndexReader, boolean, boolean)} to create a matching {@link Scorer} instance for a given {@link Collector}, or vice versa.

NOTE: the default implementation returns

CopyC#
false
, i.e. the
CopyC#
Scorer
scores documents in-order.
(Inherited from Weight.)
Public methodSumOfSquaredWeights (Overrides Weight..::..SumOfSquaredWeights()()()().)
Public methodToString
Returns a String that represents the current Object.
(Inherited from Object.)

Fields

  NameDescription
Protected fieldsimilarity
The Similarity implementation.
Protected fieldweights
The Weights for our subqueries, in 1-1 correspondence with disjuncts

Properties

  NameDescription
Public propertyEnclosing_Instance

See Also