org.apache.lucene.search.grouping.function

## Class FunctionAllGroupHeadsCollector

- java.lang.Object
- - org.apache.lucene.search.Collector
  - - org.apache.lucene.search.grouping.AbstractAllGroupHeadsCollector<FunctionAllGroupHeadsCollector.GroupHead>
    - - org.apache.lucene.search.grouping.function.FunctionAllGroupHeadsCollector

    public class FunctionAllGroupHeadsCollector
    extends AbstractAllGroupHeadsCollector<FunctionAllGroupHeadsCollector.GroupHead>

An implementation of `AbstractAllGroupHeadsCollector` for retrieving the most relevant groups when grouping by `ValueSource`.

WARNING: This API is experimental and might change in incompatible ways in the next release.

### Nested Class Summary

Nested Classes
`class` `FunctionAllGroupHeadsCollector.GroupHead` Holds current head document for a single group.

### Nested classes/interfaces inherited from class org.apache.lucene.search.grouping.AbstractAllGroupHeadsCollector

`AbstractAllGroupHeadsCollector.TemporalResult`

### Field Summary

### Fields inherited from class org.apache.lucene.search.grouping.AbstractAllGroupHeadsCollector

`compIDXEnd, reversed, temporalResult`

### Constructor Summary

Constructors
Constructor and Description
`FunctionAllGroupHeadsCollector(ValueSource groupBy, Map<?,?> vsContext, Sort sortWithinGroup)` Constructs a `FunctionAllGroupHeadsCollector` instance.

### Method Summary

Methods
`protected Collection<FunctionAllGroupHeadsCollector.GroupHead>` `getCollectedGroupHeads()` Returns the collected group heads.
`protected void` `retrieveGroupHeadAndAddIfNotExist(int doc)` Returns the group head and puts it into `AbstractAllGroupHeadsCollector.temporalResult`.
`void` `setNextReader(AtomicReaderContext context)`
`void` `setScorer(Scorer scorer)`

### Methods inherited from class org.apache.lucene.search.grouping.AbstractAllGroupHeadsCollector

`acceptsDocsOutOfOrder, collect, groupHeadsSize, retrieveGroupHeads, retrieveGroupHeads`

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

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

### Constructor Detail

#### FunctionAllGroupHeadsCollector

    public FunctionAllGroupHeadsCollector(ValueSource groupBy,
                                  Map<?,?> vsContext,
                                  Sort sortWithinGroup)

Constructs a `FunctionAllGroupHeadsCollector` instance.

Parameters:
  `groupBy` - The `ValueSource` to group by
  `vsContext` - The ValueSource context
  `sortWithinGroup` - The sort within a group

### Method Detail

#### retrieveGroupHeadAndAddIfNotExist

    protected void retrieveGroupHeadAndAddIfNotExist(int doc)
                                              throws IOException

Description copied from class: `AbstractAllGroupHeadsCollector`
Returns the group head and puts it into `AbstractAllGroupHeadsCollector.temporalResult`. If the group head wasn't encountered before then it will be added to the collected group heads.

The `AbstractAllGroupHeadsCollector.TemporalResult.stop` property will be `true` if the group head wasn't encountered before otherwise `false`.

Specified by:
  `retrieveGroupHeadAndAddIfNotExist` in class `AbstractAllGroupHeadsCollector<FunctionAllGroupHeadsCollector.GroupHead>`
Parameters:
  `doc` - The document to retrieve the group head for.
Throws:
  `IOException` - If I/O related errors occur

#### getCollectedGroupHeads

    protected Collection<FunctionAllGroupHeadsCollector.GroupHead> getCollectedGroupHeads()

Description copied from class: `AbstractAllGroupHeadsCollector`
Returns the collected group heads. Subsequent calls should return the same group heads.

Specified by:
  `getCollectedGroupHeads` in class `AbstractAllGroupHeadsCollector<FunctionAllGroupHeadsCollector.GroupHead>`
Returns:
  the collected group heads

#### setScorer

    public void setScorer(Scorer scorer)
                   throws IOException

Specified by:
  `setScorer` in class `Collector`
Throws:
  `IOException`

#### setNextReader

    public void setNextReader(AtomicReaderContext context)
                       throws IOException

Specified by:
  `setNextReader` in class `Collector`
Throws:
  `IOException`