org.apache.lucene.search.grouping

## Class AllGroupHeadsCollector<T>

- java.lang.Object
- - org.apache.lucene.search.SimpleCollector
  - - org.apache.lucene.search.grouping.AllGroupHeadsCollector<T>

- All Implemented Interfaces:
    Collector, LeafCollector
  Direct Known Subclasses:
    FunctionAllGroupHeadsCollector, TermAllGroupHeadsCollector

      public abstract class AllGroupHeadsCollector<T>
      extends SimpleCollector

  This collector specializes in collecting the most relevant document (group head) for each group that match the query.
  WARNING: This API is experimental and might change in incompatible ways in the next release.

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `AllGroupHeadsCollector.GroupHead<T>` Represents a group head.
    `protected class` | `AllGroupHeadsCollector.TemporalResult` Contains the result of group head retrieval.

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected int` | `compIDXEnd`
    `protected int[]` | `reversed`
    `protected AllGroupHeadsCollector.TemporalResult` | `temporalResult`

  - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `AllGroupHeadsCollector(int numberOfSorts)`

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `collect(int doc)`
    `protected abstract Collection<? extends AllGroupHeadsCollector.GroupHead<T>>` | `getCollectedGroupHeads()` Returns the collected group heads.
    `int` | `groupHeadsSize()`
    `protected abstract void` | `retrieveGroupHeadAndAddIfNotExist(int doc)` Returns the group head and puts it into `temporalResult`.
    `int[]` | `retrieveGroupHeads()`
    `FixedBitSet` | `retrieveGroupHeads(int maxDoc)`

    - ### Methods inherited from class org.apache.lucene.search.SimpleCollector

      `doSetNextReader, getLeafCollector, setScorer`

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

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

    - ### Methods inherited from interface org.apache.lucene.search.Collector

      `needsScores`

- - ### Field Detail

    - #### reversed

          protected final int[] reversed

    - #### compIDXEnd

          protected final int compIDXEnd

    - #### temporalResult

          protected final AllGroupHeadsCollector.TemporalResult temporalResult

  - ### Constructor Detail

    - #### AllGroupHeadsCollector

          protected AllGroupHeadsCollector(int numberOfSorts)

  - ### Method Detail

    - #### retrieveGroupHeads

          public FixedBitSet retrieveGroupHeads(int maxDoc)

      Parameters:
        `maxDoc` - The maxDoc of the top level `IndexReader`.
      Returns:
        a `FixedBitSet` containing all group heads.

    - #### retrieveGroupHeads

          public int[] retrieveGroupHeads()

      Returns:
        an int array containing all group heads. The size of the array is equal to number of collected unique groups.

    - #### groupHeadsSize

          public int groupHeadsSize()

      Returns:
        the number of group heads found for a query.

    - #### retrieveGroupHeadAndAddIfNotExist

          protected abstract void retrieveGroupHeadAndAddIfNotExist(int doc)
                                                             throws IOException

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

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

      Parameters:
        `doc` - The document to retrieve the group head for.
      Throws:
        `IOException` - If I/O related errors occur

    - #### getCollectedGroupHeads

          protected abstract Collection<? extends AllGroupHeadsCollector.GroupHead<T>> getCollectedGroupHeads()

      Returns the collected group heads. Subsequent calls should return the same group heads.
      Returns:
        the collected group heads

    - #### collect

          public void collect(int doc)
                       throws IOException

      Specified by:
        `collect` in interface `LeafCollector`
      Specified by:
        `collect` in class `SimpleCollector`
      Throws:
        `IOException`

Copyright © 2000-2018 Apache Software Foundation. All Rights Reserved.