DistinctValuesCollector (Lucene 10.5.0 grouping API)
Description: declaration: package: org.apache.lucene.search.grouping, class: DistinctValuesCollector

Package org.apache.lucene.search.grouping

# Class DistinctValuesCollector<T,R>

java.lang.Object
org.apache.lucene.search.SimpleCollector
org.apache.lucene.search.grouping.SecondPassGroupingCollector<T>
org.apache.lucene.search.grouping.DistinctValuesCollector<T,R>

All Implemented Interfaces:
  `Collector`, `LeafCollector`

public class DistinctValuesCollector<T,R> extends SecondPassGroupingCollector<T>
A second pass grouping collector that keeps track of distinct values for a specified field for the top N 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
  Description
  `static class`
  `DistinctValuesCollector.GroupCount<T,R>`
  Returned by `getGroups()`, representing the value and set of distinct values for the group.

- ## Field Summary

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

  `groupReducer, groups, groupSelector, totalGroupedHitCount, totalHitCount`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `DistinctValuesCollector(GroupSelector<T> groupSelector, Collection<SearchGroup<T>> groups, GroupSelector<R> valueSelector)`
  Create a DistinctValuesCollector

- ## Method Summary

  Modifier and Type
  Method
  Description
  `List<DistinctValuesCollector.GroupCount<T,R>>`
  `getGroups()`
  Returns all unique values for each top N group.

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

  `collect, doSetNextReader, getGroupSelector, scoreMode, 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`

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

  `setWeight`

  ### Methods inherited from interface org.apache.lucene.search.LeafCollector

  `collect, collectRange, competitiveIterator, finish`

- ## Constructor Details

  - ### DistinctValuesCollector

    public DistinctValuesCollector(GroupSelector<T> groupSelector, Collection<SearchGroup<T>> groups, GroupSelector<R> valueSelector)
    Create a DistinctValuesCollector
    Parameters:
      `groupSelector` - the group selector to determine the top-level groups
      `groups` - the top-level groups to collect for
      `valueSelector` - a group selector to determine which values to collect per-group

- ## Method Details

  - ### getGroups

    public List<DistinctValuesCollector.GroupCount<T,R>> getGroups()
    Returns all unique values for each top N group.
    Returns:
      all unique values for each top N group