Package org.apache.lucene.search
Class HnswQueueSaturationCollector
java.lang.Object
org.apache.lucene.search.KnnCollector.Decorator
org.apache.lucene.search.HnswQueueSaturationCollector
- All Implemented Interfaces:
KnnCollector
A
KnnCollector.Decorator that early exits when nearest neighbor queue keeps saturating
beyond a 'patience' parameter. This records the rate of collection of new nearest neighbors in
the delegate KnnCollector queue, at each HNSW node candidate visit. Once it saturates for
a number of consecutive node visits (e.g., the patience parameter), this early terminates.- WARNING: This API is experimental and might change in incompatible ways in the next release.
-
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 -
Method Summary
Modifier and TypeMethodDescriptionbooleancollect(int docId, float similarity) Collect the provided docId and include in the result set.booleanIf search visits too many documents, the results collector will terminate early.voidtopDocs()This drains the collected nearest kNN results and returns them in a newTopDocscollection, ordered by score descending.Methods inherited from class org.apache.lucene.search.KnnCollector.Decorator
incVisitedCount, k, minCompetitiveSimilarity, visitedCount, visitLimit
-
Method Details
-
earlyTerminated
public boolean earlyTerminated()Description copied from interface:KnnCollectorIf 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:
earlyTerminatedin interfaceKnnCollector- Overrides:
earlyTerminatedin classKnnCollector.Decorator- Returns:
- is the current result set marked as incomplete?
-
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 classKnnCollector.Decorator- Parameters:
docId- of the vector to collectsimilarity- its calculated similarity- Returns:
- true if the vector is collected
-
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 classKnnCollector.Decorator- Returns:
- The collected top documents
-
nextCandidate
public void nextCandidate() -
getSearchStrategy
- Specified by:
getSearchStrategyin interfaceKnnCollector- Overrides:
getSearchStrategyin classKnnCollector.Decorator- Returns:
- the search strategy used by this collector, can be null
-