Execute a generic query on stored documents, returning Astra DB documents.
The return value has a variable format, depending on whether the 'sort vector' is requested back from the server.
Only the n parameter is required. Omitting all other parameters results
in a query that matches each and every document found on the collection.
The method does not expose a projection directly, which is instead automatically determined based on the invocation options.
The returned documents are exactly as they come back from Astra DB (taking
into account the projection as well). A further step, namely subsequent
invocation of the convert_astra_db_document method, is required to reconstruct
codec-independent Document objects.
The reason for keeping the retrieval and the decoding steps separate is that
a caller may want to first deduplicate/discard items, in order to convert only
the items actually needed.
arun_query_raw(
self,
*,
n: int,
ids: list[str] | None = None,
filter: dict[str, Any] | None = None,
sort: dict[str, Any] | None = None,
include_similarity: bool | None = None,
include_sort_vector: bool = False,
include_embeddings: bool = False
) -> tuple[list[float] | None, AsyncIterable[DocDict]] | AsyncIterable[DocDict]| Name | Type | Description |
|---|---|---|
n* | int | amount of items to return. Fewer items than |
ids | list[str] | None | Default: Nonea list of document IDs to restrict the query to. If this is supplied, only document with an ID among the provided one will match. If further query filters are provided (i.e. metadata), matches must satisfy both requirements. |
filter | dict[str, Any] | None | Default: Nonea metadata filtering part. If provided, it must refer to
metadata keys by their bare name (such as
|
sort | dict[str, Any] | None | Default: Nonea 'sort' clause for the query, such as |
include_similarity | bool | None | Default: Nonewhether to return similarity scores with each match. Requires vector sort. |
include_sort_vector | bool | Default: Falsewhether to return the very query vector used for the ANN search alongside the iterable of results. Requires vector sort. Note that the shape of the return value depends on this parameter. |
include_embeddings | bool | Default: Falsewhether to retrieve the matches' own embedding vectors. |