Skip to main content
Creates and returns a new encrypted index. CyborgDB uses a single IVF index type, so there is no index_config parameter to choose between index variants.
All parameters after index_key are keyword-only.

Parameters

For more info on auto-generating embeddings, refer to Auto-Generate Embeddings.

Metadata Schema

metadata_schema sets the per-field indexing policy. Metadata stays schemaless — this controls how each field is indexed, not what may be stored. Fields left out inherit the default (indexed and filterable).
Three knobs per field:
  • filterable (default True) — index the field so filters on it resolve from the encrypted metadata index (pre-filter path, and the only path query_metadata() uses). Setting False still stores the field, but a filter referencing it forces the dense post-filter path on query() — cheaper writes, slower filtered queries.
  • pattern (default False) — additionally index the field for pattern matching, which is what makes $regex / $contains index-resolvable. Requires filterable=True.
  • full_text (default False) — route the field’s string value through the BM25 analyzer instead of exact-match indexing, which is what enables full-text search. Incompatible with pattern=True and with an explicit filterable=True; implies filterable=False.
On query() these are a performance hint: filters that miss the index just fall back to a post-filter over the decrypted metadata, same rows either way. On query_metadata() they are enforced — $regex / $contains on a non-pattern field, or any filter on a filterable=False field, raises ValueError.

Returns

EncryptedIndex: An instance of the newly created encrypted index.

Exceptions

  • Throws if the index name is not unique.
  • Throws if the index configuration is invalid.
  • Throws if metadata_schema sets pattern=True without filterable=True.
  • Throws if metadata_schema sets full_text=True together with pattern=True or an explicit filterable=True.
  • Throws if bm25_k1 or bm25_b is set and no field is full_text.
  • Throws if dimension is negative.
  • Throws if the index could not be created.
  • Throws if embedding_model cannot be downloaded or loaded (network or model-hub failure, offline cache miss). Often transient.

Example Usage

Automatic Setup

Explicit Setup

With TurboQuant Storage Precision

With Per-Field Metadata Policy