Parameters
| Parameter | Type | Description |
|---|---|---|
items | List[Dict[str, Any]] | A list of dictionaries, where each dictionary has the format {"id": str, "vector": List[float], "contents": Union[bytes, str], "metadata": Dict[str, str]}. |
index_key | bytes | (Optional, keyword-only) Override the per-operation index key. See Per-operation key override. |
user_id | bytes | (Optional, keyword-only) 16-byte RBAC user identifier. See Per-operation key override. |
item dictionary has the following fields:
| Parameter | Type | Description |
|---|---|---|
id | str | Unique string identifier for the item. |
vector | List[float] | Embedding vector as a list of floats (optional if index is configured to compute embeddings). |
contents | bytes or str | Item contents (optional). Accepts strings or bytes; all are encoded to bytes and encrypted before storage. Must be a str if index is configured to compute embeddings. |
metadata | Dict[str, any] | Dictionary of key-value metadata pairs associated with the vector (optional). |
If embedding auto-generation is enabled (by setting the
embedding_model parameter in create_index()), then the vector parameter is optional.
If vector provided, then it will be used (its dimensionality must match that of the embedding_model).
If vector is not provided, a vector embedding will be auto-generated from contents using sentence-transformers. contents must be text in this case.Exceptions
ValueError
ValueError
- Throws if the vector dimensions are incompatible with the index configuration.
- Throws if the index was not created or loaded yet.
RuntimeError
RuntimeError
- Throws if the vectors could not be upserted.
Example Usage
Per-operation key override
The simple calls above reuse the key supplied atcreate_index() / load_index(). You may instead pass index_key= (and user_id= for an RBAC user) to override the per-operation key. This is required in stateless/service deployments that reload the index per request:
Upsert Secondary Overload: NumPy Array Format
- A list of strings or 1D array of identifiers for the unique IDs.
- A 2D array of float32 values for the vector embeddings.
Parameters
| Parameter | Type | Description |
|---|---|---|
ids | list[str] or np.ndarray | A list of strings or 1D NumPy array of shape (num_items,) containing unique identifiers for each vector. Can be string or integer dtype. Length must match vectors. |
vectors | np.ndarray | 2D NumPy array of shape (num_items, vector_dim) with dtype=float32, representing vector embeddings. |
Exceptions
ValueError
ValueError
- Throws if the vector dimensions are incompatible with the index configuration.
- Throws if the index was not created or loaded yet.
RuntimeError
RuntimeError
- Throws if the vectors could not be upserted.