Skip to main content
Runs a metadata-only query — no query vector required. query_metadata() evaluates a filter expression entirely against the encrypted metadata index and returns the matching items. Pass text to rank matches by BM25 full-text relevance instead (see Full-text and hybrid search).

Parameters

  • Without order_by (and without text), the result is an unordered subset of matching items.
  • Items missing the order_by field (or holding a non-scalar value) sort last.
  • Metadata-only queries work on untrained indexes.
  • $type is not supported on this endpoint. $regex / $contains require the field to have been declared pattern: true in the index’s metadata_schema; a field declared filterable: false cannot be filtered on here at all. Both raise ValueError — run the same filter through query() with a vector if you need to bypass the schema constraint. Nested dot-paths (owner.name) are supported.

Returns

List[Dict[str, Any]]: One dictionary per matching item. Each carries id (str). When text is set, each also carries score (float, the BM25 score) and results are sorted by descending score; without text, there is no score key.

Exceptions

  • Throws if order_by is a dict with more than one field.
  • Throws if order_by is neither a field name (str) nor a single-field dict.
  • Throws if text is passed but the index has no full_text field, or text_fields names a field that is not full_text.
  • Throws if any text_* parameter is set without a non-empty text.
  • Throws if the query could not be executed.

Example Usage

Filter only (all matches, unordered):
Filter with operators and a result cap:
Sorted by a metadata field:
Full-text search (BM25):
For metadata syntax and supported operators, see Metadata Filtering.