Class AbstractKnnCollector

  • All Implemented Interfaces:
    Direct Known Subclasses:

    public abstract class AbstractKnnCollector
    extends Object
    implements KnnCollector
    AbstractKnnCollector is the default implementation for a knn collector used for gathering kNN results and providing topDocs from the gathered neighbors
    • Constructor Detail

      • AbstractKnnCollector

        protected AbstractKnnCollector​(int k,
                                       long visitLimit)
    • Method Detail

      • earlyTerminated

        public final boolean earlyTerminated()
        Description copied from interface: KnnCollector
        If search visits too many documents, the results collector will terminate early. Usually, this is due to some restricted filter on the document set.

        When collection is earlyTerminated, the results are not a correct representation of k nearest neighbors.

        Specified by:
        earlyTerminated in interface KnnCollector
        is the current result set marked as incomplete?
      • incVisitedCount

        public final void incVisitedCount​(int count)
        Specified by:
        incVisitedCount in interface KnnCollector
        count - increments the visited vector count, must be greater than 0.
      • visitedCount

        public final long visitedCount()
        Specified by:
        visitedCount in interface KnnCollector
        the current visited vector count
      • visitLimit

        public final long visitLimit()
        Specified by:
        visitLimit in interface KnnCollector
        the visited vector limit
      • k

        public final int k()
        Specified by:
        k in interface KnnCollector
        the expected number of collected results
      • collect

        public abstract boolean collect​(int docId,
                                        float similarity)
        Description copied from interface: KnnCollector
        Collect the provided docId and include in the result set.
        Specified by:
        collect in interface KnnCollector
        docId - of the vector to collect
        similarity - its calculated similarity
        true if the vector is collected
      • minCompetitiveSimilarity

        public abstract float minCompetitiveSimilarity()
        Description copied from interface: KnnCollector
        This method is utilized during search to ensure only competitive results are explored.

        Consequently, if this results collector wants to collect `k` results, this should return Float.NEGATIVE_INFINITY when not full.

        When full, the minimum score should be returned.

        Specified by:
        minCompetitiveSimilarity in interface KnnCollector
        the current minimum competitive similarity in the collection
      • topDocs

        public abstract 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
        The collected top documents