A
Collector that early terminates collection of documents on a per-segment basis, if the segment was sorted according to the given
Sort.
NOTE: the Collector detects sorted segments according to SortingMergePolicy, so it's best used in conjunction with it. Also, it collects up to a specified numDocsToCollect from each segment, and therefore is mostly suitable for use in conjunction with collectors such as Search.TopDocsCollector{T}, and not e.g. TotalHitCountCollector.
NOTE: If you wrap a Search.TopDocsCollector{T} that sorts in the same order as the index order, the returned TopDocs will be correct. However the total of TopDocsCollector{T}.TotalHits hit count will be underestimated since not all matching documents will have been collected.
NOTE: This Collector uses Sort.ToString() to detect whether a segment was sorted with the same Sort. This has two implications:
- if a custom comparator 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 Collector will incorrectly detect sorted segments.
@lucene.experimental