Package org.apache.lucene.search
Class ConstantScoreScorer
- java.lang.Object
-
- org.apache.lucene.search.Scorer
-
- org.apache.lucene.search.ConstantScoreScorer
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.apache.lucene.search.Scorer
Scorer.ChildScorer
-
-
Constructor Summary
Constructors Constructor Description ConstantScoreScorer(Weight weight, float score, DocIdSetIterator disi)
Constructor based on aDocIdSetIterator
which will be used to drive iteration.ConstantScoreScorer(Weight weight, float score, TwoPhaseIterator twoPhaseIterator)
Constructor based on aTwoPhaseIterator
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
docID()
Returns the doc ID that is currently being scored.DocIdSetIterator
iterator()
Return aDocIdSetIterator
over matching documents.float
score()
Returns the score of the current document matching the query.TwoPhaseIterator
twoPhaseIterator()
Optional method: Return aTwoPhaseIterator
view of thisScorer
.-
Methods inherited from class org.apache.lucene.search.Scorer
getChildren, getWeight
-
-
-
-
Constructor Detail
-
ConstantScoreScorer
public ConstantScoreScorer(Weight weight, float score, DocIdSetIterator disi)
Constructor based on aDocIdSetIterator
which will be used to drive iteration. Two phase iteration will not be supported.- Parameters:
weight
- the parent weightscore
- the score to return on each documentdisi
- the iterator that defines matching documents
-
ConstantScoreScorer
public ConstantScoreScorer(Weight weight, float score, TwoPhaseIterator twoPhaseIterator)
Constructor based on aTwoPhaseIterator
. In that case theScorer
will support two-phase iteration.- Parameters:
weight
- the parent weightscore
- the score to return on each documenttwoPhaseIterator
- the iterator that defines matching documents
-
-
Method Detail
-
iterator
public DocIdSetIterator iterator()
Description copied from class:Scorer
Return aDocIdSetIterator
over matching documents. The returned iterator will either be positioned on-1
if no documents have been scored yet,DocIdSetIterator.NO_MORE_DOCS
if all documents have been scored already, or the last document id that has been scored otherwise. The returned iterator is a view: calling this method several times will return iterators that have the same state.
-
twoPhaseIterator
public TwoPhaseIterator twoPhaseIterator()
Description copied from class:Scorer
Optional method: Return aTwoPhaseIterator
view of thisScorer
. A return value ofnull
indicates that two-phase iteration is not supported. Note that the returnedTwoPhaseIterator
'sapproximation
must advance synchronously with theScorer.iterator()
: advancing the approximation must advance the iterator and vice-versa. Implementing this method is typically useful onScorer
s that have a high per-document overhead in order to confirm matches. The default implementation returnsnull
.- Overrides:
twoPhaseIterator
in classScorer
-
docID
public int docID()
Description copied from class:Scorer
Returns the doc ID that is currently being scored. This will return-1
if theScorer.iterator()
is not positioned orDocIdSetIterator.NO_MORE_DOCS
if it has been entirely consumed.- Specified by:
docID
in classScorer
- See Also:
DocIdSetIterator.docID()
-
score
public float score() throws IOException
Description copied from class:Scorer
Returns the score of the current document matching the query. Initially invalid, untilDocIdSetIterator.nextDoc()
orDocIdSetIterator.advance(int)
is called on theScorer.iterator()
the first time, or when called from withinLeafCollector.collect(int)
.- Specified by:
score
in classScorer
- Throws:
IOException
-
-