Class DiversifyingNearestChildrenKnnCollector

  • All Implemented Interfaces:
    KnnCollector

    class DiversifyingNearestChildrenKnnCollector
    extends AbstractKnnCollector
    This collects the nearest children vectors. Diversifying the results over the provided parent filter. This means the nearest children vectors are returned, but only one per parent
    • Constructor Detail

      • DiversifyingNearestChildrenKnnCollector

        public DiversifyingNearestChildrenKnnCollector​(int k,
                                                       int visitLimit,
                                                       BitSet parentBitSet)
        Create a new object for joining nearest child kNN documents with a parent bitset
        Parameters:
        k - The number of joined parent documents to collect
        visitLimit - how many child vectors can be visited
        parentBitSet - The leaf parent bitset
    • Method Detail

      • collect

        public boolean collect​(int docId,
                               float nodeScore)
        If the heap is not full (size is less than the initialSize provided to the constructor), adds a new node-and-score element. If the heap is full, compares the score against the current top score, and replaces the top element if newScore is better than (greater than unless the heap is reversed), the current top score.

        If docId's parent node has previously been collected and the provided nodeScore is less than the stored score it will not be collected.

        Specified by:
        collect in interface KnnCollector
        Specified by:
        collect in class AbstractKnnCollector
        Parameters:
        docId - the neighbor docId
        nodeScore - the score of the neighbor, relative to some other node
        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
        Specified by:
        minCompetitiveSimilarity in class AbstractKnnCollector
        Returns:
        the current minimum competitive similarity in the collection
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • 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
        Specified by:
        topDocs in class AbstractKnnCollector
        Returns:
        The collected top documents