KnnCollectorManager (Lucene 10.5.0 core API)
Description: declaration: package: org.apache.lucene.search.knn, interface: KnnCollectorManager

Package org.apache.lucene.search.knn

# Interface KnnCollectorManager

All Known Implementing Classes:
  `TimeLimitingKnnCollectorManager`, `TopKnnCollectorManager`

public interface KnnCollectorManager
KnnCollectorManager responsible for creating `KnnCollector` instances. Useful to create `KnnCollector` instances that share global state across leaves, such a global queue of results collected so far.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `default boolean`
  `isOptimistic()`
  `KnnCollector`
  `newCollector(int visitedLimit, KnnSearchStrategy searchStrategy, LeafReaderContext context)`
  Return a new `KnnCollector` instance.
  `default KnnCollector`
  `newOptimisticCollector(int visitedLimit, KnnSearchStrategy searchStrategy, LeafReaderContext context, int k)`
  Return a new `KnnCollector` instance, generally with a specific k value, scaled per leaf statistics

- ## Method Details

  - ### newCollector

    KnnCollector newCollector(int visitedLimit, KnnSearchStrategy searchStrategy, LeafReaderContext context) throws IOException
    Return a new `KnnCollector` instance.
    Parameters:
      `visitedLimit` - the maximum number of nodes that the search is allowed to visit
      `searchStrategy` - the optional search strategy configuration
      `context` - the leaf reader context
    Throws:
      `IOException`

  - ### newOptimisticCollector

    default KnnCollector newOptimisticCollector(int visitedLimit, KnnSearchStrategy searchStrategy, LeafReaderContext context, int k) throws IOException
    Return a new `KnnCollector` instance, generally with a specific k value, scaled per leaf statistics
    Parameters:
      `visitedLimit` - the maximum number of nodes that the search is allowed to visit
      `searchStrategy` - the optional search strategy configuration
      `context` - the leaf reader context
      `k` - the number of neighbors to collect, this is the expected number of results
    Returns:
      a new KnnCollector instance
    Throws:
      `IOException` - if there is an error creating the collector

  - ### isOptimistic

    default boolean isOptimistic()