Skip to main content
Builds the index using the specified training configuration. Required before efficient querying. Prior to calling this, all queries will be conducted using encrypted exhaustive search. After, they will be conducted using encrypted ANN search.

Parameters

Training needs at least 10,000 vectors in the index and at least 2 * n_lists vectors. Below either threshold, train() does not raise: it logs a warning and leaves the index untrained. Check is_trained() afterwards.

Exceptions

  • Raises an exception if the index was not created or loaded yet.
  • Raises an exception if the index could not be trained.

Example Usage

Index key

index_key is required on every call. Pass the same 32-byte index KEK you used with create_index() / load_index(). For an RBAC user, pass the user’s KEK as index_key= together with their user_id=:
Training requires write permission. An RBAC user without a write wrap cannot train the index.