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 TypeMethodDescriptionboolean
collect
(int docId, float similarity) Collect the provided docId and include in the result set.boolean
If search visits too many documents, the results collector will terminate early.void
topDocs()
This drains the collected nearest kNN results and returns them in a newTopDocs
collection, 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: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 interfaceKnnCollector
- Overrides:
earlyTerminated
in classKnnCollector.Decorator
- Returns:
- is the current result set marked as incomplete?
-
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 interfaceKnnCollector
- Overrides:
collect
in classKnnCollector.Decorator
- Parameters:
docId
- of the vector to collectsimilarity
- its calculated similarity- Returns:
- true if the vector is collected
-
topDocs
Description copied from interface:KnnCollector
This drains the collected nearest kNN results and returns them in a newTopDocs
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 interfaceKnnCollector
- Overrides:
topDocs
in classKnnCollector.Decorator
- Returns:
- The collected top documents
-
nextCandidate
public void nextCandidate() -
getSearchStrategy
- Specified by:
getSearchStrategy
in interfaceKnnCollector
- Overrides:
getSearchStrategy
in classKnnCollector.Decorator
- Returns:
- the search strategy used by this collector, can be null
-