Class ValueSourceScorer
- java.lang.Object
-
- org.apache.lucene.search.Scorable
-
- org.apache.lucene.search.Scorer
-
- org.apache.lucene.queries.function.ValueSourceScorer
-
public abstract class ValueSourceScorer extends Scorer
Scorer
which returns the result ofFunctionValues.floatVal(int)
as the score for a document, and which filters out documents that don't matchmatches(int)
. This Scorer has aTwoPhaseIterator
. This is similar toFunctionQuery
, with an added filter.Note: If the scores are needed, then the underlying value will probably be fetched/computed twice -- once to filter and next to return the score. If that's non-trivial then consider wrapping it in an implementation that will cache the current value.
- See Also:
FunctionQuery
- WARNING: This API is experimental and might change in incompatible ways in the next release.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.apache.lucene.search.Scorable
Scorable.ChildScorable
-
-
Field Summary
Fields Modifier and Type Field Description protected FunctionValues
values
-
Constructor Summary
Constructors Modifier Constructor Description protected
ValueSourceScorer(Weight weight, LeafReaderContext readerContext, FunctionValues values)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description int
docID()
float
getMaxScore(int upTo)
DocIdSetIterator
iterator()
protected float
matchCost()
Cost evaluation function which defines the cost of access for the TwoPhaseIterator for this class This method should be overridden for specifying custom cost methods.abstract boolean
matches(int doc)
Override to decide if this document matches.float
score()
TwoPhaseIterator
twoPhaseIterator()
-
Methods inherited from class org.apache.lucene.search.Scorer
advanceShallow, getWeight
-
Methods inherited from class org.apache.lucene.search.Scorable
getChildren, setMinCompetitiveScore, smoothingScore
-
-
-
-
Field Detail
-
values
protected final FunctionValues values
-
-
Constructor Detail
-
ValueSourceScorer
protected ValueSourceScorer(Weight weight, LeafReaderContext readerContext, FunctionValues values)
-
-
Method Detail
-
matches
public abstract boolean matches(int doc) throws IOException
Override to decide if this document matches. It's called byTwoPhaseIterator.matches()
.- Throws:
IOException
-
iterator
public DocIdSetIterator iterator()
-
twoPhaseIterator
public TwoPhaseIterator twoPhaseIterator()
- Overrides:
twoPhaseIterator
in classScorer
-
score
public float score() throws IOException
- Specified by:
score
in classScorable
- Throws:
IOException
-
getMaxScore
public float getMaxScore(int upTo) throws IOException
- Specified by:
getMaxScore
in classScorer
- Throws:
IOException
-
matchCost
protected float matchCost()
Cost evaluation function which defines the cost of access for the TwoPhaseIterator for this class This method should be overridden for specifying custom cost methods. Used byTwoPhaseIterator.matchCost()
for the instance owned by this class- Returns:
- cost of access
- WARNING: This API is experimental and might change in incompatible ways in the next release.
-
-