Package org.apache.lucene.search

# Class TotalHitCountCollectorManager

java.lang.Object
org.apache.lucene.search.TotalHitCountCollectorManager

All Implemented Interfaces:
  `CollectorManager<TotalHitCountCollector,Integer>`

public class TotalHitCountCollectorManager extends Object implements CollectorManager<TotalHitCountCollector,Integer>
Collector manager based on `TotalHitCountCollector` that allows users to parallelize counting the number of hits, expected to be used mostly wrapped in `MultiCollectorManager`. For cases when this is the only collector manager used, `IndexSearcher.count(Query)` should be called instead of `IndexSearcher.search(Query, CollectorManager)` as the former is faster whenever the count can be returned directly from the index statistics.

## Constructor Summary

Constructors
Constructor
Description
`TotalHitCountCollectorManager(IndexSearcher.LeafSlice[] leafSlices)`
Creates a new total hit count collector manager, providing the array of leaf slices that search targets, which can be retrieved via `IndexSearcher.getSlices()` for the searcher.

## Method Summary

Modifier and Type
Method
Description
`TotalHitCountCollector`
`newCollector()`
Return a new `Collector`.
`Integer`
`reduce(Collection<TotalHitCountCollector> collectors)`
Reduce the results of individual collectors into a meaningful result.

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

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

## Constructor Details

### TotalHitCountCollectorManager

public TotalHitCountCollectorManager(IndexSearcher.LeafSlice[] leafSlices)
Creates a new total hit count collector manager, providing the array of leaf slices that search targets, which can be retrieved via `IndexSearcher.getSlices()` for the searcher.

Parameters:
  `leafSlices` - the slices that the searcher targets. Used to optimize the collection depending on whether segments have been partitioned into partitions or not.

## Method Details

### newCollector

public TotalHitCountCollector newCollector() throws IOException
Description copied from interface: `CollectorManager`
Return a new `Collector`. This must return a different instance on each call.

Specified by:
  `newCollector` in interface `CollectorManager<TotalHitCountCollector,Integer>`
Throws:
  `IOException`

### reduce

public Integer reduce(Collection<TotalHitCountCollector> collectors) throws IOException
Description copied from interface: `CollectorManager`
Reduce the results of individual collectors into a meaningful result. For instance a `TopDocsCollector` would compute the `top docs` of each collector and then merge them using `TopDocs.merge(int, TopDocs[])`. This method must be called after collection is finished on all provided collectors.

Specified by:
  `reduce` in interface `CollectorManager<TotalHitCountCollector,Integer>`
Throws:
  `IOException`