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
AScorerwhich 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 theCollectorinterface, 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 aScorerobject, 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 byBulkScorerwhich will throw an Exception.floatscore()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 IOExceptionDescription copied from class:ScorerReturns 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:
scorein classFilterScorer- Throws:
IOException
-
getChildren
public Collection<Scorer.ChildScorer> getChildren()
Description copied from class:ScorerReturns 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 byBulkScorerwhich will throw an Exception.- Overrides:
getChildrenin classScorer
-
-