Package org.apache.lucene.search
Class ScoringRewrite<Q extends Query>
java.lang.Object
org.apache.lucene.search.MultiTermQuery.RewriteMethod
org.apache.lucene.search.ScoringRewrite<Q>
Base rewrite method that translates each term into a query, and keeps
the scores as computed by the query.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final MultiTermQuery.RewriteMethod
LikeSCORING_BOOLEAN_QUERY_REWRITE
except scores are not computed.static final ScoringRewrite<BooleanQuery>
A rewrite method that first translates each term intoBooleanClause.Occur.SHOULD
clause in a BooleanQuery, and keeps the scores as computed by the query. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected final void
Add a MultiTermQuery term to the top-level queryprotected abstract void
addClause
(Q topLevel, Term term, int docCount, float boost, TermContext states) protected abstract void
checkMaxClauseCount
(int count) This method is called after every new term to check if the number of max clauses (e.g.protected abstract Q
Return a suitable top-level Query for holding all expanded terms.final Q
rewrite
(IndexReader reader, MultiTermQuery query) Methods inherited from class org.apache.lucene.search.MultiTermQuery.RewriteMethod
getTermsEnum
-
Field Details
-
SCORING_BOOLEAN_QUERY_REWRITE
A rewrite method that first translates each term intoBooleanClause.Occur.SHOULD
clause in a BooleanQuery, and keeps the scores as computed by the query. Note that typically such scores are meaningless to the user, and require non-trivial CPU to compute, so it's almost always better to useMultiTermQuery.CONSTANT_SCORE_AUTO_REWRITE_DEFAULT
instead.NOTE: This rewrite method will hit
BooleanQuery.TooManyClauses
if the number of terms exceedsBooleanQuery.getMaxClauseCount()
. -
CONSTANT_SCORE_BOOLEAN_QUERY_REWRITE
LikeSCORING_BOOLEAN_QUERY_REWRITE
except scores are not computed. Instead, each matching document receives a constant score equal to the query's boost.NOTE: This rewrite method will hit
BooleanQuery.TooManyClauses
if the number of terms exceedsBooleanQuery.getMaxClauseCount()
.
-
-
Constructor Details
-
ScoringRewrite
public ScoringRewrite()
-
-
Method Details
-
checkMaxClauseCount
This method is called after every new term to check if the number of max clauses (e.g. in BooleanQuery) is not exceeded. Throws the correspondingRuntimeException
.- Throws:
IOException
-
rewrite
- Specified by:
rewrite
in classMultiTermQuery.RewriteMethod
- Throws:
IOException
-
getTopLevelQuery
Return a suitable top-level Query for holding all expanded terms.- Throws:
IOException
-
addClause
Add 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
-