Retrieves the nearest neighbors for given query vectors.
QueryResults Query ( Array2D < float > & query_vectors ,
const QueryParams & query_params = QueryParams ());
Parameters
Parameter Type Description
query_vectorsArray2D<float>Query vectors to search. query_paramsQueryParams(Optional) Parameters for querying, such as top_k and n_lists.
If this function is called on an index where TrainIndex() has not been executed, the query will use encrypted exhaustive search.
This may cause queries to be slower, especially when there are many vector embeddings in the index.
Returns
QueryResults : Results top_k containing decrypted nearest neighbors IDs and distances.
Exceptions
Throws if the query vectors have incompatible dimensions with the index.
Throws if the index was not created or loaded yet.
Throws if the query could not be executed.
Example Usage
cyborg ::Array2D < float > queries{ /*...*/ }; // Populate with one or more query vectors
cyborg :: QueryParams params ( 10 , 5 ); // top_k = 10, n_probes = 5
QueryResults results = index -> Query (queries, params);
std ::cout << "ID: " << result . ids [j] << ", Distance: " << result . distances [j] << std ::endl;
// Process query results...