Package org.apache.lucene.search.knn
Class MultiLeafTopKnnCollector
- java.lang.Object
-
- org.apache.lucene.search.AbstractKnnCollector
-
- org.apache.lucene.search.TopKnnCollector
-
- org.apache.lucene.search.knn.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.
-
-
Field Summary
-
Fields inherited from class org.apache.lucene.search.TopKnnCollector
queue
-
Fields inherited from class org.apache.lucene.search.AbstractKnnCollector
visitedCount
-
-
Constructor Summary
Constructors Constructor Description MultiLeafTopKnnCollector(int k, int visitLimit, BlockingFloatHeap globalSimilarityQueue)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancollect(int docId, float similarity)Collect the provided docId and include in the result set.floatminCompetitiveSimilarity()This method is utilized during search to ensure only competitive results are explored.TopDocstopDocs()This drains the collected nearest kNN results and returns them in a newTopDocscollection, ordered by score descending.StringtoString()-
Methods inherited from class org.apache.lucene.search.AbstractKnnCollector
earlyTerminated, incVisitedCount, k, visitedCount, visitLimit
-
-
-
-
Constructor Detail
-
MultiLeafTopKnnCollector
public MultiLeafTopKnnCollector(int k, int visitLimit, BlockingFloatHeap globalSimilarityQueue)- Parameters:
k- the number of neighbors to collectvisitLimit- how many vector nodes the results are allowed to visit
-
-
Method Detail
-
collect
public boolean collect(int docId, float similarity)Description copied from interface:KnnCollectorCollect the provided docId and include in the result set.- Specified by:
collectin interfaceKnnCollector- Overrides:
collectin classTopKnnCollector- Parameters:
docId- of the vector to collectsimilarity- its calculated similarity- Returns:
- true if the vector is collected
-
minCompetitiveSimilarity
public float minCompetitiveSimilarity()
Description copied from interface:KnnCollectorThis 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_INFINITYwhen not full.When full, the minimum score should be returned.
- Specified by:
minCompetitiveSimilarityin interfaceKnnCollector- Overrides:
minCompetitiveSimilarityin classTopKnnCollector- Returns:
- the current minimum competitive similarity in the collection
-
topDocs
public TopDocs topDocs()
Description copied from interface:KnnCollectorThis drains the collected nearest kNN results and returns them in a newTopDocscollection, ordered by score descending. NOTE: This is generally a destructive action and the collector should not be used after topDocs() is called.- Specified by:
topDocsin interfaceKnnCollector- Overrides:
topDocsin classTopKnnCollector- Returns:
- The collected top documents
-
toString
public String toString()
- Overrides:
toStringin classTopKnnCollector
-
-