FileDocCategorySizeDatePackage
Scorer.javaAPI DocApache Lucene 1.4.32383Tue Mar 30 00:48:04 BST 2004org.apache.lucene.search

Scorer

public abstract class Scorer extends Object
Expert: Implements scoring for a class of queries.

Fields Summary
private Similarity
similarity
Constructors Summary
protected Scorer(Similarity similarity)
Constructs a Scorer.

    this.similarity = similarity;
  
Methods Summary
public abstract intdoc()
Returns the current document number. Initially invalid, until {@link #next()} is called the first time.

public abstract org.apache.lucene.search.Explanationexplain(int doc)
Returns an explanation of the score for doc.

public org.apache.lucene.search.SimilaritygetSimilarity()
Returns the Similarity implementation used by this scorer.

    return this.similarity;
  
public abstract booleannext()
Advance to the next document matching the query. Returns true iff there is another match.

public voidscore(org.apache.lucene.search.HitCollector hc)
Scores all documents and passes them to a collector.

    while (next()) {
      hc.collect(doc(), score());
    }
  
public abstract floatscore()
Returns the score of the current document. Initially invalid, until {@link #next()} is called the first time.

public abstract booleanskipTo(int target)
Skips to the first match beyond the current whose document number is greater than or equal to target.

Returns 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.