Package org.apache.lucene.util.hnsw
Class HnswGraphSearcher
java.lang.Object
org.apache.lucene.util.hnsw.HnswGraphSearcher
Searches an HNSW graph to find nearest neighbors to a query vector. For more background on the
search algorithm, see
HnswGraph
.-
Method Summary
Modifier and TypeMethodDescriptionstatic NeighborQueue
search
(float[] query, int topK, RandomAccessVectorValues vectors, VectorSimilarityFunction similarityFunction, HnswGraph graph, Bits acceptOrds, int visitedLimit) Searches HNSW graph for the nearest neighbors of a query vector.
-
Method Details
-
search
public static NeighborQueue search(float[] query, int topK, RandomAccessVectorValues vectors, VectorSimilarityFunction similarityFunction, HnswGraph graph, Bits acceptOrds, int visitedLimit) throws IOException Searches HNSW graph for the nearest neighbors of a query vector.- Parameters:
query
- search query vectortopK
- the number of nodes to be returnedvectors
- the vector valuessimilarityFunction
- the similarity function to compare vectorsgraph
- the graph values. May represent the entire graph, or a level in a hierarchical graph.acceptOrds
-Bits
that represents the allowed document ordinals to match, ornull
if they are all allowed to match.visitedLimit
- the maximum number of nodes that the search is allowed to visit- Returns:
- a priority queue holding the closest neighbors found
- Throws:
IOException
-