Class GraphSearcher<T>

java.lang.Object
io.github.jbellis.jvector.graph.GraphSearcher<T>

public class GraphSearcher<T> extends Object
Searches a graph to find nearest neighbors to a query vector. For more background on the search algorithm, see GraphIndex.
  • Method Details

    • search

      public static <T> SearchResult search(T targetVector, int topK, RandomAccessVectorValues<T> vectors, VectorEncoding vectorEncoding, VectorSimilarityFunction similarityFunction, GraphIndex<T> graph, Bits acceptOrds)
      Convenience function for simple one-off searches. It is caller's responsibility to make sure that it is the unique owner of the vectors instance passed in here.
    • search

      public SearchResult search(NeighborSimilarity.ScoreFunction scoreFunction, NeighborSimilarity.ReRanker<T> reRanker, int topK, Bits acceptOrds)
      Parameters:
      scoreFunction - a function returning the similarity of a given node to the query vector
      reRanker - if scoreFunction is approximate, this should be non-null and perform exact comparisons of the vectors for re-ranking at the end of the search.
      topK - the number of results to look for
      acceptOrds - a Bits instance indicating which nodes are acceptable results. If null, all nodes are acceptable. It is caller's responsibility to ensure that there are enough acceptable nodes that we don't search the entire graph trying to satisfy topK.
      Returns:
      a SearchResult containing the topK results and the number of nodes visited during the search.