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).
filterable(defaultTrue) — index the field so filters on it resolve from the encrypted metadata index (pre-filter path, and the only pathquery_metadata()uses). SettingFalsestill stores the field, but a filter referencing it forces the dense post-filter path onquery()— cheaper writes, slower filtered queries.pattern(defaultFalse) — additionally index the field for pattern matching, which is what makes$regex/$containsindex-resolvable. Requiresfilterable=True.full_text(defaultFalse) — route the field’s string value through the BM25 analyzer instead of exact-match indexing, which is what enables full-text search. Incompatible withpattern=Trueand with an explicitfilterable=True; impliesfilterable=False.
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
ValueError
ValueError
- Throws if the index name is not unique.
- Throws if the index configuration is invalid.
- Throws if
metadata_schemasetspattern=Truewithoutfilterable=True. - Throws if
metadata_schemasetsfull_text=Truetogether withpattern=Trueor an explicitfilterable=True. - Throws if
bm25_k1orbm25_bis set and no field isfull_text. - Throws if
dimensionis negative. - Throws if the index could not be created.