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

Package org.apache.lucene.misc.search

# Class DiversifiedTopDocsCollectorManager<C extends DiversifiedTopDocsCollector>

java.lang.Object
org.apache.lucene.misc.search.DiversifiedTopDocsCollectorManager<C>

All Implemented Interfaces:
  `CollectorManager<C,TopDocs>`

public abstract class DiversifiedTopDocsCollectorManager<C extends DiversifiedTopDocsCollector> extends Object implements CollectorManager<C,TopDocs>
A `CollectorManager` for `DiversifiedTopDocsCollector`. Subclasses implement `CollectorManager.newCollector()` to supply concrete collector instances; this class provides the `reduce(Collection)` that merges per-slice results while preserving the diversity constraint across the whole result set.

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

- ## Constructor Summary

  Constructors
  Modifier
  Constructor
  Description
  `protected`
  `DiversifiedTopDocsCollectorManager(int numHits, int maxHitsPerKey)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `TopDocs`
  `reduce(Collection<C> collectors)`
  Merges per-slice results into a single `TopDocs` while re-applying the diversity constraint globally.

  ### 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.CollectorManager

  `newCollector`

- ## Constructor Details

  - ### DiversifiedTopDocsCollectorManager

    protected DiversifiedTopDocsCollectorManager(int numHits, int maxHitsPerKey)
    Parameters:
      `numHits` - maximum number of results to return
      `maxHitsPerKey` - maximum number of results per key allowed in the final results

- ## Method Details

  - ### reduce

    public TopDocs reduce(Collection<C> collectors) throws IOException
    Merges per-slice results into a single `TopDocs` while re-applying the diversity constraint globally. Each per-slice collector may contain up to `numHits` results, but the same key can appear in multiple slices; `reduce` enforces `maxHitsPerKey` across all slices.
    Specified by:
      `reduce` in interface `CollectorManager<C extends DiversifiedTopDocsCollector,TopDocs>`
    Throws:
      `IOException`