public abstract class

Scorer

extends DocIdSetIterator
java.lang.Object
   ↳ org.apache.lucene.search.DocIdSetIterator
     ↳ org.apache.lucene.search.Scorer
Known Direct Subclasses
Known Indirect Subclasses

Class Overview

Expert: Common scoring functionality for different types of queries.

A Scorer iterates over documents matching a query in increasing order of doc Id.

Document scores are computed using a given Similarity implementation.

NOTE: The values Float.Nan, Float.NEGATIVE_INFINITY and Float.POSITIVE_INFINITY are not valid scores. Certain collectors (eg TopScoreDocCollector) will not properly collect hits with these scores.

Summary

[Expand]
Inherited Constants
From class org.apache.lucene.search.DocIdSetIterator
Protected Constructors
Scorer(Similarity similarity)
Constructs a Scorer.
Public Methods
Similarity getSimilarity()
Returns the Similarity implementation used by this scorer.
void score(Collector collector)
Scores and collects all matching documents.
abstract float score()
Returns the score of the current document matching the query.
Protected Methods
boolean score(Collector collector, int max, int firstDocID)
Expert: Collects matching documents in a range.
[Expand]
Inherited Methods
From class org.apache.lucene.search.DocIdSetIterator
From class java.lang.Object

Protected Constructors

protected Scorer (Similarity similarity)

Constructs a Scorer.

Parameters
similarity The Similarity implementation used by this scorer.

Public Methods

public Similarity getSimilarity ()

Returns the Similarity implementation used by this scorer.

public void score (Collector collector)

Scores and collects all matching documents.

Parameters
collector The collector to which all matching documents are passed.
Throws
IOException

public abstract float score ()

Returns the score of the current document matching the query. Initially invalid, until nextDoc() or advance(int) is called the first time, or when called from within collect(int).

Throws
IOException

Protected Methods

protected boolean score (Collector collector, int max, int firstDocID)

Expert: Collects matching documents in a range. Hook for optimization. Note, firstDocID is added to ensure that nextDoc() was called before this method.

Parameters
collector The collector to which all matching documents are passed.
max Do not score documents past this.
firstDocID The first document ID (ensures nextDoc() is called before this method.
Returns
  • true if more matching documents may remain.
Throws
IOException