Class TopFieldCollector
A ICollector that sorts by SortField using FieldComparers.
See the Create(Sort, int, bool, bool, bool, bool) method for instantiating a TopFieldCollector.Note
This API is experimental and might change in incompatible ways in the next release.
Inherited Members
Namespace: Lucene.Net.Search
Assembly: Lucene.Net.dll
Syntax
public abstract class TopFieldCollector : TopDocsCollector<FieldValueHitQueue.Entry>, ITopDocsCollector, ICollector
Properties
AcceptsDocsOutOfOrder
Return true
if this collector does not
require the matching docIDs to be delivered in int sort
order (smallest to largest) to Collect(int).
Most Lucene Query implementations will visit matching docIDs in order. However, some queries (currently limited to certain cases of BooleanQuery) can achieve faster searching if the ICollector allows them to deliver the docIDs out of order.
Many collectors don't mind getting docIDs out of
order, so it's important to return true
here.
Declaration
public override bool AcceptsDocsOutOfOrder { get; }
Property Value
Type | Description |
---|---|
bool |
Overrides
Methods
Create(Sort, int, FieldDoc?, bool, bool, bool, bool)
Creates a new TopFieldCollector from the given arguments.
NOTE: The instances returned by this method pre-allocate a full array of lengthnumHits
.
Declaration
public static TopFieldCollector Create(Sort sort, int numHits, FieldDoc? after, bool fillFields, bool trackDocScores, bool trackMaxScore, bool docsScoredInOrder)
Parameters
Type | Name | Description |
---|---|---|
Sort | sort | The sort criteria (SortFields). |
int | numHits | The number of results to collect. |
FieldDoc | after | Only hits after this FieldDoc will be collected |
bool | fillFields | Specifies whether the actual field values should be returned on the results (FieldDoc). |
bool | trackDocScores | Specifies whether document scores should be tracked and set on the
results. Note that if set to |
bool | trackMaxScore | Specifies whether the query's maxScore should be tracked and set
on the resulting TopDocs. Note that if set to |
bool | docsScoredInOrder | Specifies whether documents are scored in doc Id order or not by the given Scorer in SetScorer(Scorer). |
Returns
Type | Description |
---|---|
TopFieldCollector | A TopFieldCollector instance which will sort the results by the sort criteria. |
Exceptions
Type | Condition |
---|---|
IOException | If there is a low-level I/O error |
ArgumentNullException |
|
Create(Sort, int, bool, bool, bool, bool)
Creates a new TopFieldCollector from the given arguments.
NOTE: The instances returned by this method pre-allocate a full array of lengthnumHits
.
Declaration
public static TopFieldCollector Create(Sort sort, int numHits, bool fillFields, bool trackDocScores, bool trackMaxScore, bool docsScoredInOrder)
Parameters
Type | Name | Description |
---|---|---|
Sort | sort | The sort criteria (SortFields). |
int | numHits | The number of results to collect. |
bool | fillFields | Specifies whether the actual field values should be returned on the results (FieldDoc). |
bool | trackDocScores | Specifies whether document scores should be tracked and set on the
results. Note that if set to |
bool | trackMaxScore | Specifies whether the query's maxScore should be tracked and set
on the resulting TopDocs. Note that if set to |
bool | docsScoredInOrder | Specifies whether documents are scored in doc Id order or not by the given Scorer in SetScorer(Scorer). |
Returns
Type | Description |
---|---|
TopFieldCollector | A TopFieldCollector instance which will sort the results by the sort criteria. |
Exceptions
Type | Condition |
---|---|
IOException | If there is a low-level I/O error |
ArgumentNullException |
|
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
Type | Name | Description |
---|---|---|
ScoreDoc[] | results | |
int | start |
Returns
Type | Description |
---|---|
TopDocs |
Overrides
PopulateResults(ScoreDoc[], int)
Populates the results array with the ScoreDoc instances. This can be overridden in case a different ScoreDoc type should be returned.
Declaration
protected override void PopulateResults(ScoreDoc[] results, int howMany)
Parameters
Type | Name | Description |
---|---|---|
ScoreDoc[] | results | |
int | howMany |