jruby/docs BETA
Navigation
org.apache.lucene.util.hnsw 25
C BlockingFloatHeap
I CloseableRandomVectorScorerSupplier
C ConcurrentHnswMerger
C FilteredHnswGraphSearcher
C FloatHeap
I HasKnnVectorValues
I HnswBuilder
C HnswConcurrentMergeBuilder
C HnswGraph
C HnswGraphBuilder
I HnswGraphMerger
C HnswGraphSearcher
C HnswUtil
C IncrementalHnswGraphMerger
C InitializedHnswGraphBuilder
I IntToIntFunction
C MergingHnswGraphBuilder
C NeighborArray
C NeighborQueue
C OnHeapHnswGraph
C OrdinalTranslatedKnnCollector
I RandomVectorScorer
I RandomVectorScorerSupplier
C UpdateGraphsUtils
I UpdateableRandomVectorScorer
HnswGraphSearcher — members 6+
C new(candidates, visited)
M expected_visited_nodes(k, graph_size) int
C search(scorer, knn_collector, graph, accept_ords)
C search(scorer, knn_collector, graph, accept_ords, filtered_doc_count)
M search(scorer, top_k, graph, accept_ords, visited_limit) KnnCollector
M search_level(scorer, top_k, level, eps, graph) GraphBuilderKnnCollector
from AbstractHnswGraphSearcher
C search(results, scorer, graph, accept_ords)

org.apache.lucene.util.hnsw.HnswGraphSearcher

class extends AbstractHnswGraphSearcher 6 members

Searches an HNSW graph to find nearest neighbors to a query vector. For more background on the search algorithm, see HnswGraph.

Constructors

new

new ( NeighborQueue candidates, BitSet visited )
Java: <init>(org.apache.lucene.util.hnsw.NeighborQueue candidates, org.apache.lucene.util.BitSet visited)

Creates a new graph searcher.

nametypedescription
candidatesorg.apache.lucene.util.hnsw.NeighborQueuemax heap that will track the candidate nodes to explore
visitedorg.apache.lucene.util.BitSetbit set that will track nodes that have already been visited

Class Methods

expected_visited_nodes

int expected_visited_nodes ( int k, int graph_size )
Java: expectedVisitedNodes(int k, int graphSize)

HNSW search is roughly logarithmic. This doesn't take maxConn into account, but it is a pretty good approximation.

nametypedescription
kintneighbors to find
graph_sizeintsize of the graph

Returns: expected number of visited nodes

Instance Methods

search_level

HnswGraphBuilder.GraphBuilderKnnCollector search_level ( RandomVectorScorer scorer, int top_k, int level, int[] eps, HnswGraph graph )
Java: searchLevel(org.apache.lucene.util.hnsw.RandomVectorScorer scorer, int topK, int level, int[] eps, org.apache.lucene.util.hnsw.HnswGraph graph)

Searches for the nearest neighbors of a query vector in a given level.

If the search stops early because it reaches the visited nodes limit, then the results will be marked incomplete through NeighborQueue#incomplete().

nametypedescription
scorerorg.apache.lucene.util.hnsw.RandomVectorScorerthe scorer to compare the query with the nodes
top_kintthe number of nearest to query results to return
levelintlevel to search
epsint[]the entry points for search at this level expressed as level 0th ordinals
graphorg.apache.lucene.util.hnsw.HnswGraphthe graph values

Returns: a set of collected vectors holding the nearest neighbors found

Inherited

from AbstractHnswGraphSearcher

this work for additional information regarding copyright ownership.