Class TopScoreDocCollector
A ICollector implementation that collects the top-scoring hits,
returning them as a TopDocs. this is used by IndexSearcher to
implement TopDocs-based search. Hits are sorted by score descending
and then (when the scores are tied) docID ascending. When you create an
instance of this collector you should know in advance whether documents are
going to be collected in doc Id order or not.
NOTE: The values
NaN and
NegativeInfinity are not valid scores. This
collector will not properly collect hits with such
scores.
Inheritance
TopScoreDocCollector
Assembly: Lucene.Net.dll
Syntax
public abstract class TopScoreDocCollector : TopDocsCollector<ScoreDoc>, ITopDocsCollector, ICollector
Methods
Create(int, ScoreDoc?, bool)
Creates a new TopScoreDocCollector given the number of hits to
collect, the bottom of the previous page, and whether documents are scored in order by the input
Scorer to SetScorer(Scorer).
NOTE: The instances returned by this method
pre-allocate a full array of length
numHits
, and fill the array with sentinel
objects.
Declaration
public static TopScoreDocCollector Create(int numHits, ScoreDoc? after, bool docsScoredInOrder)
Parameters
Returns
Create(int, bool)
Creates a new TopScoreDocCollector given the number of hits to
collect and whether documents are scored in order by the input
Scorer to SetScorer(Scorer).
NOTE: The instances returned by this method
pre-allocate a full array of length
numHits
, and fill the array with sentinel
objects.
Declaration
public static TopScoreDocCollector Create(int numHits, bool docsScoredInOrder)
Parameters
Type |
Name |
Description |
int |
numHits |
|
bool |
docsScoredInOrder |
|
Returns
NewTopDocs(ScoreDoc[]?, int)
Returns a TopDocs instance containing the given results. If
results
is null
it means there are no results to return,
either because there were 0 calls to Collect(int) or because the arguments to
TopDocs were invalid.
Declaration
protected override TopDocs NewTopDocs(ScoreDoc[]? results, int start)
Parameters
Returns
Overrides
SetNextReader(AtomicReaderContext)
Declaration
public override void SetNextReader(AtomicReaderContext context)
Parameters
Overrides
SetScorer(Scorer)
Called before successive calls to Collect(int). Implementations
that need the score of the current document (passed-in to
Collect(int)), should save the passed-in Scorer and call
GetScore() when needed.
Declaration
public override void SetScorer(Scorer scorer)
Parameters
Type |
Name |
Description |
Scorer |
scorer |
|
Overrides
Implements