Package org.apache.lucene.search
Class TopTermsRewrite<Q extends Query>
- java.lang.Object
-
- org.apache.lucene.search.MultiTermQuery.RewriteMethod
-
- org.apache.lucene.search.TopTermsRewrite<Q>
-
- Direct Known Subclasses:
MultiTermQuery.TopTermsBoostOnlyBooleanQueryRewrite,MultiTermQuery.TopTermsScoringBooleanQueryRewrite
public abstract class TopTermsRewrite<Q extends Query> extends MultiTermQuery.RewriteMethod
Base rewrite method for collecting only the top terms via a priority queue.
-
-
Constructor Summary
Constructors Constructor Description TopTermsRewrite(int size)Create a TopTermsBooleanQueryRewrite for at mostsizeterms.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected voidaddClause(Q topLevel, Term term, int docCount, float boost)Add a MultiTermQuery term to the top-level queryprotected abstract voidaddClause(Q topLevel, Term term, int docCount, float boost, TermContext states)booleanequals(Object obj)protected abstract intgetMaxSize()return the maximum size of the priority queue (for boolean rewrites this is BooleanQuery#getMaxClauseCount).intgetSize()return the maximum priority queue sizeprotected abstract QgetTopLevelQuery()Return a suitable top-level Query for holding all expanded terms.inthashCode()Qrewrite(IndexReader reader, MultiTermQuery query)-
Methods inherited from class org.apache.lucene.search.MultiTermQuery.RewriteMethod
getTermsEnum
-
-
-
-
Constructor Detail
-
TopTermsRewrite
public TopTermsRewrite(int size)
Create a TopTermsBooleanQueryRewrite for at mostsizeterms.NOTE: if
BooleanQuery.getMaxClauseCount()is smaller thansize, then it will be used instead.
-
-
Method Detail
-
getSize
public int getSize()
return the maximum priority queue size
-
getMaxSize
protected abstract int getMaxSize()
return the maximum size of the priority queue (for boolean rewrites this is BooleanQuery#getMaxClauseCount).
-
rewrite
public final Q rewrite(IndexReader reader, MultiTermQuery query) throws IOException
- Specified by:
rewritein classMultiTermQuery.RewriteMethod- Throws:
IOException
-
getTopLevelQuery
protected abstract Q getTopLevelQuery() throws IOExceptionReturn a suitable top-level Query for holding all expanded terms.- Throws:
IOException
-
addClause
protected final void addClause(Q topLevel, Term term, int docCount, float boost) throws IOExceptionAdd a MultiTermQuery term to the top-level query- Throws:
IOException
-
addClause
protected abstract void addClause(Q topLevel, Term term, int docCount, float boost, TermContext states) throws IOException- Throws:
IOException
-
-