org.apache.lucene.search.grouping.term

## Class TermFirstPassGroupingCollector

- java.lang.Object
- - org.apache.lucene.search.SimpleCollector
  - - org.apache.lucene.search.grouping.AbstractFirstPassGroupingCollector<BytesRef>
    - - org.apache.lucene.search.grouping.term.TermFirstPassGroupingCollector

- All Implemented Interfaces:
    Collector, LeafCollector

      public class TermFirstPassGroupingCollector
      extends AbstractFirstPassGroupingCollector<BytesRef>

  Concrete implementation of `AbstractFirstPassGroupingCollector` that groups based on field values and more specifically uses `SortedDocValues` to collect groups.
  WARNING: This API is experimental and might change in incompatible ways in the next release.

- - ### Field Summary

    - ### Fields inherited from class org.apache.lucene.search.grouping.AbstractFirstPassGroupingCollector

      `orderedGroups`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `TermFirstPassGroupingCollector(String groupField, Sort groupSort, int topNGroups)` Create the first pass collector.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected BytesRef` | `copyDocGroupValue(BytesRef groupValue, BytesRef reuse)` Returns a copy of the specified group value by creating a new instance and copying the value from the specified groupValue in the new instance.
    `protected void` | `doSetNextReader(LeafReaderContext readerContext)`
    `protected BytesRef` | `getDocGroupValue(int doc)` Returns the group value for the specified doc.

    - ### Methods inherited from class org.apache.lucene.search.grouping.AbstractFirstPassGroupingCollector

      `collect, getTopGroups, needsScores, setScorer`

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

      `getLeafCollector`

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

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

- - ### Constructor Detail

    - #### TermFirstPassGroupingCollector

          public TermFirstPassGroupingCollector(String groupField,
                                        Sort groupSort,
                                        int topNGroups)
                                         throws IOException

      Create the first pass collector.
      Parameters:
        `groupField` - The field used to group documents. This field must be single-valued and indexed (DocValues is used to access its value per-document).
        `groupSort` - The `Sort` used to sort the groups. The top sorted document within each group according to groupSort, determines how that group sorts against other groups. This must be non-null, ie, if you want to groupSort by relevance use Sort.RELEVANCE.
        `topNGroups` - How many top groups to keep.
      Throws:
        `IOException` - When I/O related errors occur

  - ### Method Detail

    - #### getDocGroupValue

          protected BytesRef getDocGroupValue(int doc)

      Description copied from class: `AbstractFirstPassGroupingCollector`
      Returns the group value for the specified doc.
      Specified by:
        `getDocGroupValue` in class `AbstractFirstPassGroupingCollector<BytesRef>`
      Parameters:
        `doc` - The specified doc
      Returns:
        the group value for the specified doc

    - #### copyDocGroupValue

          protected BytesRef copyDocGroupValue(BytesRef groupValue,
                                   BytesRef reuse)

      Description copied from class: `AbstractFirstPassGroupingCollector`
      Returns a copy of the specified group value by creating a new instance and copying the value from the specified groupValue in the new instance. Or optionally the reuse argument can be used to copy the group value in.
      Specified by:
        `copyDocGroupValue` in class `AbstractFirstPassGroupingCollector<BytesRef>`
      Parameters:
        `groupValue` - The group value to copy
        `reuse` - Optionally a reuse instance to prevent a new instance creation
      Returns:
        a copy of the specified group value

    - #### doSetNextReader

          protected void doSetNextReader(LeafReaderContext readerContext)
                                  throws IOException

      Overrides:
        `doSetNextReader` in class `AbstractFirstPassGroupingCollector<BytesRef>`
      Throws:
        `IOException`

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