Class EarlyTerminatingSortingCollector
A ICollector that early terminates collection of documents on a per-segment basis, if the segment was sorted according to the given Sort.
NOTE: the ICollector detects sorted segments according to SortingMergePolicy, so it's best used in conjunction with it. Also, it collects up to a specified m_numDocsToCollect from each segment, and therefore is mostly suitable for use in conjunction with collectors such as TopDocsCollector<T>, and not e.g. TotalHitCountCollector.
NOTE: If you wrap a TopDocsCollector<T> that sorts in the same order as the index order, the returned GetTopDocs() will be correct. However the total of TotalHits hit count will be underestimated since not all matching documents will have been collected.
NOTE: This ICollector uses ToString() to detect whether a segment was sorted with the same Sort. This has two implications:
- if a custom comparer is not implemented correctly and returns different identifiers for equivalent instances, this collector will not detect sorted segments,
- if you suddenly change the IndexWriter's SortingMergePolicy to sort according to another criterion and if both the old and the new Sorts have the same identifier, this ICollector will incorrectly detect sorted segments.
Inheritance
Implements
Inherited Members
Namespace: Lucene.Net.Index.Sorter
Assembly: Lucene.Net.Misc.dll
Syntax
public class EarlyTerminatingSortingCollector : ICollector
Constructors
| Improve this Doc View SourceEarlyTerminatingSortingCollector(ICollector, Sort, Int32)
Create a new EarlyTerminatingSortingCollector instance.
Declaration
public EarlyTerminatingSortingCollector(ICollector in, Sort sort, int numDocsToCollect)
Parameters
Type | Name | Description |
---|---|---|
ICollector | in | the collector to wrap |
Sort | sort | the sort you are sorting the search results on |
System.Int32 | numDocsToCollect | the number of documents to collect on each segment. When wrapping a TopDocsCollector<T>, this number should be the number of hits. |
Fields
| Improve this Doc View Sourcem_in
The wrapped Collector
Declaration
protected readonly ICollector m_in
Field Value
Type | Description |
---|---|
ICollector |
m_numDocsToCollect
Number of documents to collect in each segment
Declaration
protected readonly int m_numDocsToCollect
Field Value
Type | Description |
---|---|
System.Int32 |
m_segmentSorted
True if the current segment being processed is sorted by Sort()
Declaration
protected bool m_segmentSorted
Field Value
Type | Description |
---|---|
System.Boolean |
m_segmentTotalCollect
Number of documents to collect in the current segment being processed
Declaration
protected int m_segmentTotalCollect
Field Value
Type | Description |
---|---|
System.Int32 |
m_sort
Sort used to sort the search results
Declaration
protected readonly Sort m_sort
Field Value
Type | Description |
---|---|
Sort |
Properties
| Improve this Doc View SourceAcceptsDocsOutOfOrder
Declaration
public virtual bool AcceptsDocsOutOfOrder { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
Methods
| Improve this Doc View SourceCollect(Int32)
Declaration
public virtual void Collect(int doc)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | doc |
SetNextReader(AtomicReaderContext)
Declaration
public virtual void SetNextReader(AtomicReaderContext context)
Parameters
Type | Name | Description |
---|---|---|
AtomicReaderContext | context |
SetScorer(Scorer)
Declaration
public virtual void SetScorer(Scorer scorer)
Parameters
Type | Name | Description |
---|---|---|
Scorer | scorer |