org.apache.lucene.search

## Class EarlyTerminatingSortingCollector

- java.lang.Object
- - org.apache.lucene.search.FilterCollector
  - - org.apache.lucene.search.EarlyTerminatingSortingCollector

All Implemented Interfaces:
  Collector

Deprecated.
Pass trackTotalHits=false to `TopFieldCollector` instead of using this class.

    @Deprecated
    public class EarlyTerminatingSortingCollector
    extends FilterCollector

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 segments sorted according to a an `IndexWriterConfig.setIndexSort(org.apache.lucene.search.Sort)`. Also, it collects up to a specified `numDocsToCollect` from each segment, and therefore is mostly suitable for use in conjunction with collectors such as `TopDocsCollector`, and not e.g. `TotalHitCountCollector`.

NOTE: If you wrap a `TopDocsCollector` that sorts in the same order as the index order, the returned `TopDocs` will be correct. However the total of `hit count` will be vastly underestimated since not all matching documents will have been collected.

### Field Summary

Fields
`protected int` `numDocsToCollect` Deprecated. Number of documents to collect in each segment
`protected Sort` `sort` Deprecated. Sort used to sort the search results

### Fields inherited from class org.apache.lucene.search.FilterCollector

`in`

### Constructor Summary

Constructors
Constructor and Description
`EarlyTerminatingSortingCollector(Collector in, Sort sort, int numDocsToCollect)` Deprecated. Create a new `EarlyTerminatingSortingCollector` instance.

### Method Summary

All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods
`static boolean` `canEarlyTerminate(Sort searchSort, Sort mergePolicySort)` Deprecated. Returns whether collection can be early-terminated if it sorts with the provided `Sort` and if segments are merged with the provided `Sort`.
`LeafCollector` `getLeafCollector(LeafReaderContext context)` Deprecated. Create a new `collector` to collect the given context.
`boolean` `terminatedEarly()` Deprecated.

### Methods inherited from class org.apache.lucene.search.FilterCollector

`needsScores, toString`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

### Field Detail

#### sort

    protected final Sort sort

Deprecated.
Sort used to sort the search results

#### numDocsToCollect

    protected final int numDocsToCollect

Deprecated.
Number of documents to collect in each segment

### Constructor Detail

#### EarlyTerminatingSortingCollector

    public EarlyTerminatingSortingCollector(Collector in,
                                            Sort sort,
                                            int numDocsToCollect)

Deprecated.
Create a new `EarlyTerminatingSortingCollector` instance.

Parameters:
  `in` - the collector to wrap
  `sort` - the sort you are sorting the search results on
  `numDocsToCollect` - the number of documents to collect on each segment. When wrapping a `TopDocsCollector`, this number should be the number of hits.
Throws:
  `IllegalArgumentException` - if the sort order doesn't allow for early termination with the given merge policy.

### Method Detail

#### canEarlyTerminate

    public static boolean canEarlyTerminate(Sort searchSort,
                                            Sort mergePolicySort)

Deprecated.
Returns whether collection can be early-terminated if it sorts with the provided `Sort` and if segments are merged with the provided `Sort`.

#### getLeafCollector

    public LeafCollector getLeafCollector(LeafReaderContext context)
                                   throws IOException

Deprecated.
Description copied from interface: `Collector`
Create a new `collector` to collect the given context.

Specified by:
  `getLeafCollector` in interface `Collector`
Overrides:
  `getLeafCollector` in class `FilterCollector`
Parameters:
  `context` - next atomic reader context
Throws:
  `IOException`

#### terminatedEarly

    public boolean terminatedEarly()

Deprecated.