Module org.apache.lucene.core
Package org.apache.lucene.search
Class AbstractMultiTermQueryConstantScoreWrapper.RewritingWeight
java.lang.Object
org.apache.lucene.search.Weight
org.apache.lucene.search.ConstantScoreWeight
org.apache.lucene.search.AbstractMultiTermQueryConstantScoreWrapper.RewritingWeight
- All Implemented Interfaces:
SegmentCacheable
- Enclosing class:
AbstractMultiTermQueryConstantScoreWrapper<Q extends MultiTermQuery>
protected abstract static class AbstractMultiTermQueryConstantScoreWrapper.RewritingWeight
extends ConstantScoreWeight
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.lucene.search.Weight
Weight.DefaultBulkScorer, Weight.DefaultScorerSupplier
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final MultiTermQuery
private final ScoreMode
private final IndexSearcher
Fields inherited from class org.apache.lucene.search.Weight
parentQuery
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
RewritingWeight
(MultiTermQuery q, float boost, ScoreMode scoreMode, IndexSearcher searcher) -
Method Summary
Modifier and TypeMethodDescriptionprivate boolean
collectTerms
(int fieldDocCount, TermsEnum termsEnum, List<AbstractMultiTermQueryConstantScoreWrapper.TermAndState> terms) private static long
estimateCost
(Terms terms, long queryTermsCount) boolean
matches
(LeafReaderContext context, int doc) ReturnsMatches
for a specific document, ornull
if the document does not match the parent queryrewriteAsBooleanQuery
(LeafReaderContext context, List<AbstractMultiTermQueryConstantScoreWrapper.TermAndState> collectedTerms) protected abstract AbstractMultiTermQueryConstantScoreWrapper.WeightOrDocIdSetIterator
rewriteInner
(LeafReaderContext context, int fieldDocCount, Terms terms, TermsEnum termsEnum, List<AbstractMultiTermQueryConstantScoreWrapper.TermAndState> collectedTerms) Rewrite the query as either aWeight
or aDocIdSetIterator
wrapped in aAbstractMultiTermQueryConstantScoreWrapper.WeightOrDocIdSetIterator
.private Scorer
scorerForIterator
(DocIdSetIterator iterator) scorerSupplier
(LeafReaderContext context) Get aScorerSupplier
, which allows knowing the cost of theScorer
before building it.Methods inherited from class org.apache.lucene.search.ConstantScoreWeight
explain, score
Methods inherited from class org.apache.lucene.search.Weight
bulkScorer, count, getQuery, scorer
-
Field Details
-
q
-
scoreMode
-
searcher
-
-
Constructor Details
-
RewritingWeight
protected RewritingWeight(MultiTermQuery q, float boost, ScoreMode scoreMode, IndexSearcher searcher)
-
-
Method Details
-
rewriteInner
protected abstract AbstractMultiTermQueryConstantScoreWrapper.WeightOrDocIdSetIterator rewriteInner(LeafReaderContext context, int fieldDocCount, Terms terms, TermsEnum termsEnum, List<AbstractMultiTermQueryConstantScoreWrapper.TermAndState> collectedTerms) throws IOException Rewrite the query as either aWeight
or aDocIdSetIterator
wrapped in aAbstractMultiTermQueryConstantScoreWrapper.WeightOrDocIdSetIterator
. Before this is called, the weight will attempt to "collect" found terms up to a threshold. If fewer terms than the threshold are found, the query will simply be rewritten into aBooleanQuery
and this method will not be called. This will only be called if it is determined there are more found terms. At the point this method is invoked,termsEnum
will be positioned on the next "uncollected" term. The terms that were already collected will be incollectedTerms
.- Throws:
IOException
-
rewriteAsBooleanQuery
private AbstractMultiTermQueryConstantScoreWrapper.WeightOrDocIdSetIterator rewriteAsBooleanQuery(LeafReaderContext context, List<AbstractMultiTermQueryConstantScoreWrapper.TermAndState> collectedTerms) throws IOException - Throws:
IOException
-
collectTerms
private boolean collectTerms(int fieldDocCount, TermsEnum termsEnum, List<AbstractMultiTermQueryConstantScoreWrapper.TermAndState> terms) throws IOException - Throws:
IOException
-
scorerForIterator
-
matches
Description copied from class:Weight
ReturnsMatches
for a specific document, ornull
if the document does not match the parent queryA query match that contains no position information (for example, a Point or DocValues query) will return
MatchesUtils.MATCH_WITH_NO_TERMS
- Overrides:
matches
in classWeight
- Parameters:
context
- the reader's context to create theMatches
fordoc
- the document's id relative to the given context's reader- Throws:
IOException
-
scorerSupplier
Description copied from class:Weight
Get aScorerSupplier
, which allows knowing the cost of theScorer
before building it. A scorer supplier for the sameLeafReaderContext
instance may be requested multiple times as part of a single search call.Note: It must return null if the scorer is null.
- Specified by:
scorerSupplier
in classWeight
- Parameters:
context
- the leaf reader context- Returns:
- a
ScorerSupplier
providing the scorer, or null if scorer is null - Throws:
IOException
- if an IOException occurs- See Also:
-
estimateCost
- Throws:
IOException
-
isCacheable
- Returns:
true
if the object can be cached against a given leaf
-