Package io.github.jbellis.jvector.graph
Class GraphSearcher<T>
java.lang.Object
io.github.jbellis.jvector.graph.GraphSearcher<T>
Searches a graph to find nearest neighbors to a query vector. For more background on the
search algorithm, see
GraphIndex.-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionsearch(NeighborSimilarity.ScoreFunction scoreFunction, NeighborSimilarity.ReRanker<T> reRanker, int topK, Bits acceptOrds) static <T> SearchResultsearch(T targetVector, int topK, RandomAccessVectorValues<T> vectors, VectorEncoding vectorEncoding, VectorSimilarityFunction similarityFunction, GraphIndex<T> graph, Bits acceptOrds) Convenience function for simple one-off searches.
-
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 vectorreRanker- 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 foracceptOrds- 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.
-