Package org.apache.lucene.search

# Class TotalHitCountCollector

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

All Implemented Interfaces:
  `Collector`

public class TotalHitCountCollector extends Object implements Collector
Just counts the total number of hits. This is the collector behind `IndexSearcher.count(org.apache.lucene.search.Query)`. When the `Weight` implements `Weight.count(org.apache.lucene.index.LeafReaderContext)`, this collector will skip collecting segments.

## Constructor Summary

Constructors
Constructor
Description
`TotalHitCountCollector()`

## Method Summary

Modifier and Type
Method
Description
`protected final LeafCollector`
`createLeafCollector()`
`LeafCollector`
`getLeafCollector(LeafReaderContext context)`
Create a new `collector` to collect the given context.
`int`
`getTotalHits()`
Returns how many hits matched the search.
`ScoreMode`
`scoreMode()`
Indicates what features are required from the scorer.
`void`
`setWeight(Weight weight)`
Set the `Weight` that will be used to produce scorers that will feed `LeafCollector`s.

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

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

## Constructor Details

### TotalHitCountCollector

public TotalHitCountCollector()

## Method Details

### getTotalHits

public int getTotalHits()
Returns how many hits matched the search.

### scoreMode

public ScoreMode scoreMode()
Description copied from interface: `Collector`
Indicates what features are required from the scorer.

Specified by:
  `scoreMode` in interface `Collector`

### setWeight

public void setWeight(Weight weight)
Description copied from interface: `Collector`
Set the `Weight` that will be used to produce scorers that will feed `LeafCollector`s. This is typically useful to have access to `Weight.count(org.apache.lucene.index.LeafReaderContext)` from `Collector.getLeafCollector(org.apache.lucene.index.LeafReaderContext)`.

Specified by:
  `setWeight` in interface `Collector`

### getLeafCollector

public LeafCollector getLeafCollector(LeafReaderContext context) throws IOException
Description copied from interface: `Collector`
Create a new `collector` to collect the given context.

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

### createLeafCollector

protected final LeafCollector createLeafCollector()