Database
Architecture
Vectors
Upsert vectors
The upsert
operation writes vectors into a namespace. If a new value is upserted for an existing vector ID, it will overwrite the previous value.
For guidance and examples, see Upsert data.
POST
/
vectors
/
upsert
# pip install "pinecone[grpc]"
from pinecone.grpc import PineconeGRPC as Pinecone
pc = Pinecone(api_key="YOUR_API_KEY")
# To get the unique host for an index,
# see https://docs.pinecone.io/guides/manage-data/target-an-index
index = pc.Index(host="INDEX_HOST")
upsert_response = index.upsert(
vectors=[
{
"id": "vec1",
"values": [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8],
"sparse_values": {
"indices": [1, 5],
"values": [0.5, 0.5]
},
"metadata": {
"genre": "drama"
}
},
{
"id": "vec2",
"values": [0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9],
"sparse_values": {
"indices": [5, 6],
"values": [0.4, 0.5]
},
"metadata": {
"genre": "action"
}
}
],
namespace="example-namespace"
)
{"upsertedCount":2}
# pip install "pinecone[grpc]"
from pinecone.grpc import PineconeGRPC as Pinecone
pc = Pinecone(api_key="YOUR_API_KEY")
# To get the unique host for an index,
# see https://docs.pinecone.io/guides/manage-data/target-an-index
index = pc.Index(host="INDEX_HOST")
upsert_response = index.upsert(
vectors=[
{
"id": "vec1",
"values": [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8],
"sparse_values": {
"indices": [1, 5],
"values": [0.5, 0.5]
},
"metadata": {
"genre": "drama"
}
},
{
"id": "vec2",
"values": [0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9],
"sparse_values": {
"indices": [5, 6],
"values": [0.4, 0.5]
},
"metadata": {
"genre": "action"
}
}
],
namespace="example-namespace"
)
{"upsertedCount":2}
Authorizations
Body
application/json
The request for the upsert
operation.
Response
200
application/json
A successful response.
The response for the upsert
operation.
Was this page helpful?
# pip install "pinecone[grpc]"
from pinecone.grpc import PineconeGRPC as Pinecone
pc = Pinecone(api_key="YOUR_API_KEY")
# To get the unique host for an index,
# see https://docs.pinecone.io/guides/manage-data/target-an-index
index = pc.Index(host="INDEX_HOST")
upsert_response = index.upsert(
vectors=[
{
"id": "vec1",
"values": [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8],
"sparse_values": {
"indices": [1, 5],
"values": [0.5, 0.5]
},
"metadata": {
"genre": "drama"
}
},
{
"id": "vec2",
"values": [0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9],
"sparse_values": {
"indices": [5, 6],
"values": [0.4, 0.5]
},
"metadata": {
"genre": "action"
}
}
],
namespace="example-namespace"
)
{"upsertedCount":2}