Upsert
.upsert() stores one or more vectors in a collection. If a vector with the given ID already exists, it is updated. If it doesn’t exist, it is inserted.
Basic usage
Parameters
| Field | Type | Required | Description |
|---|---|---|---|
id | string | ✅ | Unique identifier for this vector. Must be unique within the collection. |
values | number[] | ✅ | The vector values. Length must exactly match the collection’s dimensions. |
metadata | Record<string, any> | ❌ | Any JSON-serializable object. Returned with query results. |
Batch upsert
Pass multiple vectors in a single call. One Solana transaction is posted regardless of batch size - batching is always more efficient than individual upserts.Updating existing vectors
Upsert by the same ID to update a vector:What happens after upsert
- HNSW insert (~2ms) - vector is immediately available for queries
- Encryption (sync) - AES-256-GCM encryption before any persistence
- Shadow Drive upload (async) - encrypted vector written to decentralized storage
- Solana Merkle root (async) - new Merkle root posted on-chain