org.apache.lucene.search
abstract public class: Scorer [javadoc |
source]
java.lang.Object
org.apache.lucene.search.DocIdSetIterator
org.apache.lucene.search.Scorer
Direct Known Subclasses:
TermScorer, NonMatchingScorer, ReqOptSumScorer, MatchAllScorer, SpanScorer, ReqExclScorer, DisjunctionSumScorer, PhraseScorer, CustomScorer, SloppyPhraseScorer, ConjunctionScorer, BoostingSpanScorer, DisjunctionMaxScorer, BooleanScorer2, SingleMatchScorer, ConstantScorer, ExactPhraseScorer, ValueSourceScorer
Expert: Common scoring functionality for different types of queries.
A Scorer either iterates over documents matching a
query in increasing order of doc Id, or provides an explanation of
the score for a query for a given document.
Document scores are computed using a given Similarity
implementation.
Also see:
- BooleanQuery#setAllowDocsOutOfOrder
| Constructor: |
protected Scorer(Similarity similarity) {
this.similarity = similarity;
}
Parameters:
similarity - The Similarity implementation used by this scorer.
|
| Methods from org.apache.lucene.search.DocIdSetIterator: |
|---|
|
doc, next, skipTo |
| Method from org.apache.lucene.search.Scorer Detail: |
abstract public Explanation explain(int doc) throws IOException
|
public Similarity getSimilarity() {
return this.similarity;
}
Returns the Similarity implementation used by this scorer. |
abstract public float score() throws IOException
Returns the score of the current document matching the query.
Initially invalid, until #next() or #skipTo(int)
is called the first time. |
public void score(HitCollector hc) throws IOException {
while (next()) {
hc.collect(doc(), score());
}
}
Scores and collects all matching documents. |
protected boolean score(HitCollector hc,
int max) throws IOException {
while (doc() < max) {
hc.collect(doc(), score());
if (!next())
return false;
}
return true;
}
Expert: Collects matching documents in a range. Hook for optimization.
Note that #next() must be called once before this method is called
for the first time. |