MultiTermQuery
An abstract Query that matches documents containing a subset of terms provided by a FilteredTermsEnum enumeration.
This query cannot be used directly; you must subclass it and define .getTermsEnum to provide a FilteredTermsEnum that iterates through the terms to be matched.
NOTE: if RewriteMethod is either .CONSTANT_SCORE_BOOLEAN_REWRITE or .SCORING_BOOLEAN_REWRITE, you may encounter a IndexSearcher.TooManyClauses exception during searching, which happens when the number of terms to be searched exceeds IndexSearcher.getMaxClauseCount. Setting RewriteMethod to .CONSTANT_SCORE_BLENDED_REWRITE or .CONSTANT_SCORE_REWRITE prevents this.
The recommended rewrite method is .CONSTANT_SCORE_BLENDED_REWRITE: it doesn't spend CPU computing unhelpful scores, and is the most performant rewrite method given the query. If you need scoring (like FuzzyQuery, use TopTermsScoringBooleanQueryRewrite which uses a priority queue to only collect competitive terms and not hit this limitation.
Note that org.gnit.lucenekmp.queryparser.classic.QueryParser produces MultiTermQueries using .CONSTANT_SCORE_REWRITE by default.
Inheritors
Types
Abstract class that defines how the query is rewritten.
A rewrite method that first translates each term into BooleanClause.Occur.SHOULD clause in a BooleanQuery, but adjusts the frequencies used for scoring to be blended across the terms, otherwise the rarest term typically ranks highest (often not useful eg in the set of expanded terms in a FuzzyQuery).
A rewrite method that first translates each term into BooleanClause.Occur.SHOULD clause in a BooleanQuery, but the scores are only computed as the boost.
A rewrite method that first translates each term into BooleanClause.Occur.SHOULD clause in a BooleanQuery, and keeps the scores as computed by the query.
Functions
Expert: Constructs an appropriate Weight implementation for this query.
Override and implement query instance equivalence properly in a subclass. This is required so that QueryCache works properly.
Constructs an enumeration that expands the pattern term. This method should only be called if the field exists (ie, implementations can assume the field does exist). This method never returns null. The returned TermsEnum is positioned to the first matching term.
To rewrite to a simpler form, instead return a simpler enum from .getTermsEnum. For example, to rewrite to a single term, return a SingleTermsEnum
Recurse through the query tree, visiting any child queries.