org.apache.lucene.search
Class ReqOptSumScorer
public class ReqOptSumScorer
A Scorer for queries with a required part and an optional part.
Delays skipTo() on the optional part until a score() is needed.
This
Scorer
implements
Scorer.skipTo(int)
.
int | doc() - Returns the current document number matching the query.
|
Explanation | explain(int doc) - Explain the score of a document.
|
boolean | next() - Advances to the next document matching the query.
|
float | score() - Returns the score of the current document matching the query.
|
boolean | skipTo(int target) - Skips to the first match beyond the current whose document number is
greater than or equal to a given target.
|
ReqOptSumScorer
public ReqOptSumScorer(Scorer reqScorer,
Scorer optScorer)
Construct a ReqOptScorer
.
reqScorer
- The required scorer. This must match.optScorer
- The optional scorer. This is used for scoring only.
doc
public int doc()
Returns the current document number matching the query.
Initially invalid, until
Scorer.next()
is called the first time.
- doc in interface Scorer
explain
public Explanation explain(int doc)
throws IOException
Explain the score of a document.
- explain in interface Scorer
- Also show the total score.
See BooleanScorer.explain() on how to do this.
next
public boolean next()
throws IOException
Advances to the next document matching the query.
- next in interface Scorer
- true iff there is another document matching the query.
When this method is used the Scorer.explain(int)
method should not be used.
score
public float score()
throws IOException
Returns the score of the current document matching the query.
Initially invalid, until
next()
is called the first time.
- score in interface Scorer
- The score of the required scorer, eventually increased by the score
of the optional scorer when it also matches the current document.
skipTo
public boolean skipTo(int target)
throws IOException
Skips to the first match beyond the current whose document number is
greater than or equal to a given target.
When this method is used the
Scorer.explain(int)
method should not be used.
- skipTo in interface Scorer
target
- The target document number.
- true iff there is such a match.
Behaves as if written:
boolean skipTo(int target) {
do {
if (!next())
return false;
} while (target > doc());
return true;
}
Most implementations are considerably more efficient than that.
Copyright © 2000-2007 Apache Software Foundation. All Rights Reserved.