Skip to main content
Retrieves the nearest neighbors for given query vectors.

Parameters

Both query_params and key are required. There are no longer default values for these arguments.
If this function is called on an index where TrainIndex() has not been executed (or while a retrain is in progress), 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.
  • Throws if the supplied key context lacks read permission.

Example Usage

index_key is the 32-byte std::array<uint8_t, 32> index KEK and converts implicitly to a KeyContext. In a stateless service that reloads the index per request, pass the key on every operation.