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

Package org.apache.lucene.search.grouping

# Class FirstPassGroupingCollectorManager<T>

java.lang.Object
org.apache.lucene.search.grouping.FirstPassGroupingCollectorManager<T>

All Implemented Interfaces:
  `CollectorManager<FirstPassGroupingCollector<T>,Collection<SearchGroup<T>>>`

public class FirstPassGroupingCollectorManager<T> extends Object implements CollectorManager<FirstPassGroupingCollector<T>,Collection<SearchGroup<T>>>
A CollectorManager implementation for `FirstPassGroupingCollector` that supports parallel collection and merges results across segments.

Example usage:

     IndexSearcher searcher = new IndexSearcher(reader);
     Sort groupSort = Sort.RELEVANCE;
     int topNGroups = 10;

     FirstPassGroupingCollectorManager<BytesRef> manager =
         new FirstPassGroupingCollectorManager<>(
             () -> new TermGroupSelector("category"),
             groupSort,
             0,
             topNGroups);

     Collection<SearchGroup<BytesRef>> searchGroups = searcher.search(query, manager);

     // searchGroups can then be passed to a second pass collector manager like TopGroupsCollectorManager for full group results

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

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `FirstPassGroupingCollectorManager(Supplier<GroupSelector<T>> groupSelectorFactory, Sort groupSort, int groupOffset, int topNGroups)`
  Creates a new FirstPassGroupingCollectorManager.
  `FirstPassGroupingCollectorManager(Supplier<GroupSelector<T>> groupSelectorFactory, Sort groupSort, int groupOffset, int topNGroups, boolean ignoreDocsWithoutGroupField)`
  Creates a new FirstPassGroupingCollectorManager.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `FirstPassGroupingCollector<T>`
  `newCollector()`
  `Collection<SearchGroup<T>>`
  `reduce(Collection<FirstPassGroupingCollector<T>> collectors)`

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

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

- ## Constructor Details

  - ### FirstPassGroupingCollectorManager

    public FirstPassGroupingCollectorManager(Supplier<GroupSelector<T>> groupSelectorFactory, Sort groupSort, int groupOffset, int topNGroups)
    Creates a new FirstPassGroupingCollectorManager.
    Parameters:
      `groupSelectorFactory` - factory to create group selectors for each collector
      `groupSort` - the sort to use for groups
      `groupOffset` - The offset in the collected groups
      `topNGroups` - the number of top groups to collect

  - ### FirstPassGroupingCollectorManager

    public FirstPassGroupingCollectorManager(Supplier<GroupSelector<T>> groupSelectorFactory, Sort groupSort, int groupOffset, int topNGroups, boolean ignoreDocsWithoutGroupField)
    Creates a new FirstPassGroupingCollectorManager.
    Parameters:
      `groupSelectorFactory` - factory to create group selectors for each collector
      `groupSort` - the sort to use for groups
      `groupOffset` - The offset in the collected groups
      `topNGroups` - the number of top groups to collect
      `ignoreDocsWithoutGroupField` - whether to ignore documents without a group field

- ## Method Details

  - ### newCollector

    public FirstPassGroupingCollector<T> newCollector() throws IOException
    Specified by:
      `newCollector` in interface `CollectorManager<FirstPassGroupingCollector<T>,Collection<SearchGroup<T>>>`
    Throws:
      `IOException`

  - ### reduce

    public Collection<SearchGroup<T>> reduce(Collection<FirstPassGroupingCollector<T>> collectors) throws IOException
    Specified by:
      `reduce` in interface `CollectorManager<FirstPassGroupingCollector<T>,Collection<SearchGroup<T>>>`
    Throws:
      `IOException`