org.apache.lucene.search.grouping.term

## Class TermDistinctValuesCollector

- java.lang.Object
- - org.apache.lucene.search.SimpleCollector
  - - org.apache.lucene.search.grouping.DistinctValuesCollector<BytesRef>
    - - org.apache.lucene.search.grouping.term.TermDistinctValuesCollector

- All Implemented Interfaces:
    Collector, LeafCollector

      public class TermDistinctValuesCollector
      extends DistinctValuesCollector<BytesRef>

  A term based implementation of `DistinctValuesCollector` that relies on `SortedDocValues` to count the distinct values per group.
  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` | `TermDistinctValuesCollector.TermGroupCount` Holds distinct values for a single group.

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

      `DistinctValuesCollector.GroupCount<T>`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `TermDistinctValuesCollector(String groupField, String countField, Collection<SearchGroup<BytesRef>> groups)` Constructs `TermDistinctValuesCollector` instance.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `collect(int doc)`
    `protected void` | `doSetNextReader(LeafReaderContext context)`
    `List<DistinctValuesCollector.GroupCount<BytesRef>>` | `getGroups()` Returns all unique values for each top N group.

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

      `needsScores`

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

      `getLeafCollector, setScorer`

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

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

- - ### Constructor Detail

    - #### TermDistinctValuesCollector

          public TermDistinctValuesCollector(String groupField,
                                             String countField,
                                             Collection<SearchGroup<BytesRef>> groups)

      Constructs `TermDistinctValuesCollector` instance.
      Parameters:
        `groupField` - The field to group by
        `countField` - The field to count distinct values for
        `groups` - The top N groups, collected during the first phase search

  - ### Method Detail

    - #### collect

          public void collect(int doc)
                       throws IOException

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

    - #### getGroups

          public List<DistinctValuesCollector.GroupCount<BytesRef>> getGroups()

      Description copied from class: `DistinctValuesCollector`
      Returns all unique values for each top N group.
      Specified by:
        `getGroups` in class `DistinctValuesCollector<BytesRef>`
      Returns:
        all unique values for each top N group

    - #### doSetNextReader

          protected void doSetNextReader(LeafReaderContext context)
                                  throws IOException

      Overrides:
        `doSetNextReader` in class `SimpleCollector`
      Throws:
        `IOException`

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