Methods
Theupsert method enables you to insert or update vectors in the index.
You can perform upsert operations in three ways: using a vector object, a tuple, or a dictionary.
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
upsert method enables you to insert or update vectors in the index.
You can perform upsert operations in three ways: using a vector object, a tuple, or a dictionary.
import random
from upstash_vector import Index, Vector
index = Index.from_env()
dimension = 128 # Adjust based on your index's dimension
upsert_amount = 100
vectors = [
Vector(
id=f"generated-id-{i}",
vector=[random.random() for _ in range(dimension)],
metadata={"some_field": f"some_value-{i}"},
data=f"some-unstructured-data-{i}",
)
for i in range(upsert_amount)
]
index.upsert(vectors=vectors)
import random
from upstash_vector import Index
index = Index.from_env()
dimension = 128 # Adjust based on your index's dimension
upsert_amount = 100
vectors = [
(
f"generated-id-{i}",
[random.random() for _ in range(dimension)],
{"some_field": f"some_value-{i}"},
f"some-unstructured-data-{i}",
)
for i in range(upsert_amount)
]
index.upsert(vectors=vectors)
import random
from upstash_vector import Index
index = Index.from_env()
dimension = 128 # Adjust based on your index's dimension
upsert_amount = 100
vectors = [
{
"id": f"generated-id-{i}",
"vector": [random.random() for _ in range(dimension)],
"metadata": {"some_field": f"some_value-{i}"},
"data": f"some-unstructured-data-{i}",
}
for i in range(upsert_amount)
]
index.upsert(vectors=vectors)
index.upsert(..., namespace="ns")
Was this page helpful?