Namespace Lucene.Net.Index.Sorter
Provides index sorting capablities. The application can use any Sort specification, e.g. to sort by fields using DocValues or FieldCache, or to reverse the order of the documents (by using SortField.Type.DOC in reverse). Multi-level sorts can be specified the same way you would when searching, by building Sort from multiple SortFields.
Sorting
Sorted segments allow for early query termination when the sort order matches index order. This makes query execution faster since not all documents need to be visited. Please note that this is an expert feature and should not be used without a deep understanding of Lucene merging and document collection.
Classes
BlockJoinComparerSource
Helper class to sort readers that contain blocks of documents.
Note that this class is intended to used with Sorting
- Cannot yet be used with
IndexSearcher.SearchAfter - Filling sort field values is not yet supported.
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
Sorting
NOTE: If you wrap a TopDocsCollector<T> that sorts in the same
order as the index order, the returned Get
NOTE: This ICollector uses To
- 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 Index
Writer 's SortingMerge 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.Policy
SortingAtomicReader
An Atomic
IndexWriter writer; // writer to which the sorted index will be added
DirectoryReader reader; // reader on the input index
Sort sort; // determines how the documents are sorted
AtomicReader sortingReader = SortingAtomicReader.Wrap(SlowCompositeReaderWrapper.Wrap(reader), sort);
writer.AddIndexes(reader);
reader.Dispose(); // alternatively, you can use a using block
writer.Dispose(); // alternatively, you can use a using block
SortingMergePolicy
A Merge
NOTE: Never use this policy if you rely on
NOTE: This policy should only be used with idempotent Sorts so that the order of segments is predictable. For example, using INDEXORDER in reverse (which is not idempotent) will make the order of documents in a segment depend on the number of times the segment has been merged. @lucene.experimental