Package org.apache.lucene.search
Class MultiTermQuery.TopTermsBlendedFreqScoringRewrite
java.lang.Object
org.apache.lucene.search.MultiTermQuery.RewriteMethod
org.apache.lucene.search.TopTermsRewrite<BlendedTermQuery.Builder>
org.apache.lucene.search.MultiTermQuery.TopTermsBlendedFreqScoringRewrite
- Enclosing class:
- MultiTermQuery
public static final class MultiTermQuery.TopTermsBlendedFreqScoringRewrite
extends TopTermsRewrite<BlendedTermQuery.Builder>
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).
This rewrite method only uses the top scoring terms so it will not overflow the boolean max clause count.
-
Constructor Summary
ConstructorDescriptionTopTermsBlendedFreqScoringRewrite
(int size) Create a TopTermsBlendedScoringBooleanQueryRewrite for at mostsize
terms. -
Method Summary
Modifier and TypeMethodDescriptionprotected final void
addClause
(BlendedTermQuery.Builder topLevel, Term term, int docCount, float boost) Add a MultiTermQuery term to the top-level query builder.protected void
addClause
(BlendedTermQuery.Builder topLevel, Term term, int docCount, float boost, TermStates states) protected Query
build
(BlendedTermQuery.Builder builder) Finalize the creation of the query from the builder.protected int
return the maximum size of the priority queue (for boolean rewrites this is BooleanQuery#getMaxClauseCount).protected BlendedTermQuery.Builder
Return a suitable builder for the top-level Query for holding all expanded terms.Methods inherited from class org.apache.lucene.search.TopTermsRewrite
equals, getSize, hashCode, rewrite
Methods inherited from class org.apache.lucene.search.MultiTermQuery.RewriteMethod
getTermsEnum
-
Constructor Details
-
TopTermsBlendedFreqScoringRewrite
public TopTermsBlendedFreqScoringRewrite(int size) Create a TopTermsBlendedScoringBooleanQueryRewrite for at mostsize
terms.NOTE: if
IndexSearcher.getMaxClauseCount()
is smaller thansize
, then it will be used instead.
-
-
Method Details
-
getMaxSize
protected int getMaxSize()Description copied from class:TopTermsRewrite
return the maximum size of the priority queue (for boolean rewrites this is BooleanQuery#getMaxClauseCount).- Specified by:
getMaxSize
in classTopTermsRewrite<BlendedTermQuery.Builder>
-
getTopLevelBuilder
Return a suitable builder for the top-level Query for holding all expanded terms. -
build
Finalize the creation of the query from the builder. -
addClause
protected void addClause(BlendedTermQuery.Builder topLevel, Term term, int docCount, float boost, TermStates states) -
addClause
protected final void addClause(BlendedTermQuery.Builder topLevel, Term term, int docCount, float boost) throws IOException Add a MultiTermQuery term to the top-level query builder.- Throws:
IOException
-