Class MultiLeafTopKnnCollector

  • All Implemented Interfaces:
    KnnCollector

    public final class MultiLeafTopKnnCollector
    extends TopKnnCollector
    MultiLeafTopKnnCollector is a specific KnnCollector that can exchange the top collected results across segments through a shared global queue.
    WARNING: This API is experimental and might change in incompatible ways in the next release.
    • Constructor Detail

      • MultiLeafTopKnnCollector

        public MultiLeafTopKnnCollector​(int k,
                                        int visitLimit,
                                        BlockingFloatHeap globalSimilarityQueue)
        Parameters:
        k - the number of neighbors to collect
        visitLimit - how many vector nodes the results are allowed to visit
    • Method Detail

      • collect

        public 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
        Overrides:
        collect in class TopKnnCollector
        Parameters:
        docId - of the vector to collect
        similarity - its calculated similarity
        Returns:
        true if the vector is collected
      • minCompetitiveSimilarity

        public 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
        Overrides:
        minCompetitiveSimilarity in class TopKnnCollector
        Returns:
        the current minimum competitive similarity in the collection
      • 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 TopKnnCollector
        Returns:
        The collected top documents