Class Search
java.lang.Object
com.apple.foundationdb.async.hnsw.Search
An implementation of the search operations of the hierarchical Navigable Small World (HNSW) algorithm for efficient
approximate nearest neighbor (ANN) search.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionGets the subspace associated with this object.CompletableFuture<List<? extends ResultEntry>>kNearestNeighborsRingSearch(ReadTransaction readTransaction, int k, int efSearch, boolean includeVectors, RealVector queryVector, double radius) Performs a search for the k-nearest neighbors of a ring around a given query vector at a given radius.CompletableFuture<List<? extends ResultEntry>>kNearestNeighborsSearch(ReadTransaction readTransaction, int k, int efSearch, boolean includeVectors, RealVector queryVector) Performs a search for the k-nearest neighbors for a given query vector.
-
Constructor Details
-
Search
This constructor initializes a new search operations object with the necessary components for storage, execution, configuration, and event handling. All parameters are mandatory and must not be null.- Parameters:
locator- theLocatorwhere the graph data is stored, which config to use, which executor to use, etc.
-
-
Method Details
-
getLocator
-
getSubspace
Gets the subspace associated with this object.- Returns:
- the non-null subspace
-
kNearestNeighborsSearch
@Nonnull public CompletableFuture<List<? extends ResultEntry>> kNearestNeighborsSearch(@Nonnull ReadTransaction readTransaction, int k, int efSearch, boolean includeVectors, @Nonnull RealVector queryVector) Performs a search for the k-nearest neighbors for a given query vector.- Parameters:
readTransaction- the transaction to use for reading from the databasek- the number of nearest neighbors to returnefSearch- the size of the dynamic candidate list for the search. A larger value increases accuracy at the cost of performance.includeVectors- indicator if the caller would like the search to also include vectors in the result setqueryVector- the vector to find the nearest neighbors for- Returns:
- a
CompletableFuturethat will complete with a list of theknearest neighbors, sorted by distance in ascending order.
-
kNearestNeighborsRingSearch
@Nonnull public CompletableFuture<List<? extends ResultEntry>> kNearestNeighborsRingSearch(@Nonnull ReadTransaction readTransaction, int k, int efSearch, boolean includeVectors, @Nonnull RealVector queryVector, double radius) Performs a search for the k-nearest neighbors of a ring around a given query vector at a given radius.- Parameters:
readTransaction- the transaction to use for reading from the databasek- the number of nearest neighbors to returnefSearch- the size of the dynamic candidate list for the search. A larger value increases accuracy at the cost of performance.includeVectors- indicator if the caller would like the search to also include vectors in the result setqueryVector- the vector to find the nearest neighbors for- Returns:
- a
CompletableFuturethat will complete with a list of theknearest neighbors, sorted by distance in ascending order.
-