Package org.apache.lucene.util.hnsw

# Class OrdinalTranslatedKnnCollector

java.lang.Object
org.apache.lucene.search.KnnCollector.Decorator
org.apache.lucene.util.hnsw.OrdinalTranslatedKnnCollector

All Implemented Interfaces:
  `KnnCollector`

public final class OrdinalTranslatedKnnCollector extends KnnCollector.Decorator
Wraps a provided KnnCollector object, translating the provided vectorId ordinal to a documentId

- ## Nested Class Summary

  ## Nested classes/interfaces inherited from interface org.apache.lucene.search.KnnCollector

  `KnnCollector.Decorator`

- ## Field Summary

  ### Fields inherited from class org.apache.lucene.search.KnnCollector.Decorator

  `collector`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `OrdinalTranslatedKnnCollector(KnnCollector collector, IntToIntFunction vectorOrdinalToDocId)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `boolean`
  `collect(int vectorId, float similarity)`
  Collect the provided docId and include in the result set.
  `TopDocs`
  `topDocs()`
  This drains the collected nearest kNN results and returns them in a new `TopDocs` collection, ordered by score descending.

  ### Methods inherited from class org.apache.lucene.search.KnnCollector.Decorator

  `earlyTerminated, getSearchStrategy, incVisitedCount, k, minCompetitiveSimilarity, visitedCount, visitLimit`

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

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

- ## Constructor Details

  - ### OrdinalTranslatedKnnCollector

    public OrdinalTranslatedKnnCollector(KnnCollector collector, IntToIntFunction vectorOrdinalToDocId)

- ## Method Details

  - ### collect

    public boolean collect(int vectorId, float similarity)
    Description copied from interface: `KnnCollector`
    Collect the provided docId and include in the result set.
    Specified by:
      `collect` in interface `KnnCollector`
    Overrides:
      `collect` in class `KnnCollector.Decorator`
    Parameters:
      `vectorId` - of the vector to collect
      `similarity` - its calculated similarity
    Returns:
      true if the vector is collected

  - ### topDocs

    public TopDocs topDocs()
    Description copied from interface: `KnnCollector`
    This drains the collected nearest kNN results and returns them in a new `TopDocs` collection, ordered by score descending. NOTE: This is generally a destructive action and the collector should not be used after topDocs() is called.
    Specified by:
      `topDocs` in interface `KnnCollector`
    Overrides:
      `topDocs` in class `KnnCollector.Decorator`
    Returns:
      The collected top documents