Package org.apache.lucene.search
Class ScoreCachingWrappingScorer
- java.lang.Object
-
- org.apache.lucene.search.Scorer
-
- org.apache.lucene.search.FilterScorer
-
- org.apache.lucene.search.ScoreCachingWrappingScorer
-
public class ScoreCachingWrappingScorer extends FilterScorer
AScorer
which wraps another scorer and caches the score of the current document. Successive calls toscore()
will return the same result and will not invoke the wrapped Scorer's score() method, unless the current document has changed.
This class might be useful due to the changes done to theCollector
interface, in which the score is not computed for a document by default, only if the collector requests it. Some collectors may need to use the score in several places, however all they have in hand is aScorer
object, and might end up computing the score of a document more than once.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.apache.lucene.search.Scorer
Scorer.ChildScorer
-
-
Field Summary
-
Fields inherited from class org.apache.lucene.search.FilterScorer
in
-
-
Constructor Summary
Constructors Constructor Description ScoreCachingWrappingScorer(Scorer scorer)
Creates a new instance by wrapping the given scorer.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Collection<Scorer.ChildScorer>
getChildren()
Returns child sub-scorers positioned on the current document Note that this method should not be called on Scorers passed toLeafCollector.setScorer(Scorer)
, as these may be synthetic Scorers produced byBulkScorer
which will throw an Exception.float
score()
Returns the score of the current document matching the query.-
Methods inherited from class org.apache.lucene.search.FilterScorer
docID, iterator, twoPhaseIterator
-
-
-
-
Constructor Detail
-
ScoreCachingWrappingScorer
public ScoreCachingWrappingScorer(Scorer scorer)
Creates a new instance by wrapping the given scorer.
-
-
Method Detail
-
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)
.- Overrides:
score
in classFilterScorer
- Throws:
IOException
-
getChildren
public Collection<Scorer.ChildScorer> getChildren()
Description copied from class:Scorer
Returns child sub-scorers positioned on the current document Note that this method should not be called on Scorers passed toLeafCollector.setScorer(Scorer)
, as these may be synthetic Scorers produced byBulkScorer
which will throw an Exception.- Overrides:
getChildren
in classScorer
-
-