Class HnswGraphSearcher

java.lang.Object
org.apache.lucene.util.hnsw.HnswGraphSearcher

public final class HnswGraphSearcher extends Object
Searches an HNSW graph to find nearest neighbors to a query vector. For more background on the search algorithm, see HnswGraph.
  • 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 vector
      topK - the number of nodes to be returned
      vectors - the vector values
      similarityFunction - the similarity function to compare vectors
      graph - 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, or null 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