org.apache.lucene.search

Class Scorer


public abstract class Scorer
extends java.lang.Object

Expert: Implements scoring for a class of queries.

Constructor Summary

Scorer(Similarity similarity)
Constructs a Scorer.

Method Summary

abstract int
doc()
Returns the current document number.
abstract Explanation
explain(int doc)
Returns an explanation of the score for doc.
Similarity
getSimilarity()
Returns the Similarity implementation used by this scorer.
abstract boolean
next()
Advance to the next document matching the query.
abstract float
score()
Returns the score of the current document.
void
score(HitCollector hc)
Scores all documents and passes them to a collector.
abstract boolean
skipTo(int target)
Skips to the first match beyond the current whose document number is greater than or equal to target.

Constructor Details

Scorer

protected Scorer(Similarity similarity)
Constructs a Scorer.

Method Details

doc

public abstract int doc()

explain

public abstract Explanation explain(int doc)
            throws IOException
Returns an explanation of the score for doc.

getSimilarity

public Similarity getSimilarity()
Returns the Similarity implementation used by this scorer.

next

public abstract boolean next()
            throws IOException
Advance to the next document matching the query. Returns true iff there is another match.

score

public abstract float score()
            throws IOException

score

public void score(HitCollector hc)
            throws IOException
Scores all documents and passes them to a collector.

skipTo

public abstract boolean skipTo(int target)
            throws IOException
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.

Copyright © 2000-2006 Apache Software Foundation. All Rights Reserved.