Example Calls
Update
Methods
The update
method enables you to update the vector
, metadata
, or data
of a vector.
Update Example
from upstash_vector import Index
index = Index.from_env()
updated = index.update(
id="id1",
metadata={"new": "metadata"},
data="new-data",
)
print(updated)
Patch Metadata Example
It is also possible to patch metadata (update or delete existing fields or set new fields) according the JSON Merge Patch algorithm.
from upstash_vector import Index
from upstash_vector.types import MetadataUpdateMode
index = Index.from_env()
updated = index.update(
id="id2",
metadata={
"existing-field": "new-value",
"existing-field-to-delete": None,
"new-field": "new-value",
},
metadata_update_mode=MetadataUpdateMode.PATCH,
)
print(updated)
Also, you can specify a namespace to operate on. When no namespace is provided, the default namespace will be used.
index.update(..., namespace="ns")