Single Query
Retrieves the nearest neighbors for a given query vector.Parameters
If embedding auto-generation is enabled (by setting the
embedding_model parameter in create_index(), then the query_contents parameter can be used instead of query_vectors.Returns
List[Dict[str, Union[int, float, Dict[]]]]: List of results for the query vector. Each result is a list of top_k dictionaries, each containing id, as well as distance, metadata, and vector based on include.
Exceptions
ValueError
ValueError
- Throws if the query vector has incompatible dimensions with the index.
- Throws if the index was not created or loaded yet.
RuntimeError
RuntimeError
- Throws if the query could not be executed.
Example Usage
Single Query with Distances:Batched Queries
Retrieves the nearest neighbors for one or more query vectors.Parameters
Returns
List[List[Dict[str, Union[int, float, Dict[]]]]]: List of results for each query vector. Each result is a list of top_k dictionaries, each containing id, as well as distance and metadata based on include.
Exceptions
ValueError
ValueError
- Throws if the query vectors have incompatible dimensions with the index.
- Throws if the index was not created or loaded yet.
RuntimeError
RuntimeError
- Throws if the query could not be executed.