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]}. |
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, str or Image | Item contents (optional). Must be a str or Image 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
Upsert Secondary Overload: NumPy Array Format
- A 1D array of identifiers (strings or integers) for the unique IDs.
- A 2D array of float32 values for the vector embeddings.
Parameters
| Parameter | Type | Description |
|---|---|---|
ids | np.ndarray | 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.