Updating Vectors

1. Updating Vector Values

Example: Update Values

index.update(
    id="doc1",
    values=[0.11, 0.22, ...],  # new dense vector
)
Note: An upsert with same ID also replaces values; update() only changes the specified fields.

2. Updating Vector Metadata

Example: Set Metadata

index.update(
    id="doc1",
    set_metadata={"status": "archived", "version": 3},
)
ParamBehavior
set_metadataMerges with existing metadata (partial update)
Upsert with metadataReplaces entire metadata object

3. Updating Sparse Values

Example: Update Sparse

index.update(
    id="doc1",
    sparse_values={"indices": [1, 7, 42], "values": [0.5, 0.3, 0.2]},
)

4. Updating in Specific Namespace

Example: Namespaced Update

index.update(id="u1", set_metadata={"plan": "pro"}, namespace="users")
BehaviorDetail
Wrong namespaceNo-op (no error)
Default""

5. Performing Partial Metadata Updates

OperationResult
set_metadata={"k": v}Adds or overwrites key k
Other keysPreserved unchanged
Delete a keyNot supported; re-upsert vector without it

6. Replacing Full Metadata

Example: Full Replace via Upsert

index.upsert(vectors=[{
    "id": "doc1",
    "values": existing_values,
    "metadata": {"status": "final"},  # replaces all metadata
}])

7. Updating Multiple Vectors

Example: Batch Update via Upsert

updates = [
    {"id": v["id"], "values": v["values"], "metadata": v["metadata"]}
    for v in updated_vectors
]
index.upsert(vectors=updates)
Note: update() only handles one ID at a time. For bulk changes, prefer batched upsert.

8. Validating Update Operations

Example: Verify Update

index.update(id="d1", set_metadata={"v": 2})
got = index.fetch(ids=["d1"])
assert got["vectors"]["d1"]["metadata"]["v"] == 2

9. Handling Update Conflicts

ScenarioStrategy
Concurrent updatesLast write wins; use version field
Race with deleteIdempotent: update on missing = no-op
Optimistic concurrencyCheck version metadata before write

10. Optimizing Update Performance

TipEffect
Batch via upsert1 call vs N update calls
Partial metadata onlyAvoid re-uploading values
Parallel asyncUse thread/worker pool
Group by namespaceBetter connection reuse