Skip to main content
Pinecone Docs

Search documentation

Type to search this documentation.

On this pageOverview

Update a vector

For guidance and examples, see Update data.

Python
# pip install "pinecone[grpc]"
from pinecone.grpc import PineconeGRPC as Pinecone

pc = Pinecone(api_key="YOUR_API_KEY")
index = pc.Index("docs-example")

index.update(
	id="id-3", 
	values=[4.0, 2.0], 
	set_metadata={"genre": "comedy"},
	namespace="example-namespace"
)
JavaScript
// npm install @pinecone-database/pinecone
import { Pinecone } from '@pinecone-database/pinecone'

const pc = new Pinecone({ apiKey: "YOUR_API_KEY" })
const index = pc.index("docs-example")

await index.namespace('example-namespace').update({
  id: 'id-3',
  values: [4.0, 2.0],
  metadata: {
    type: "comedy",
  },
});
Java
import com.google.protobuf.Struct;
import com.google.protobuf.Value;
import io.pinecone.clients.Index;
import io.pinecone.clients.Pinecone;
import io.pinecone.proto.UpdateResponse;

import java.util.Arrays;
import java.util.List;

public class UpdateExample {
    public static void main(String[] args) {
        Pinecone pc = new Pinecone.Builder("YOUR_API_KEY").build();
        Index index = pc.getIndexConnection("docs-example");
        List<Float> values = Arrays.asList(4.0f, 2.0f);
		Struct metaData = Struct.newBuilder()
			.putFields("type",
					Value.newBuilder().setStringValue("comedy").build())
			.build();
        UpdateResponse updateResponse = index.update("id-3", values, metaData, "example-namespace", null, null);
        System.out.println(updateResponse);
    }
}
curl
# The `POST` request below uses the unique endpoint for an index.
# See https://docs.pinecone.io/guides/manage-data/target-an-index for details.
PINECONE_API_KEY="YOUR_API_KEY"
INDEX_HOST="INDEX_HOST"

curl "https://$INDEX_HOST/vectors/update" \
  -H "Api-Key: $PINECONE_API_KEY" \
  -H "Content-Type: application/json" \
  -H "X-Pinecone-Api-Version: 2024-04" \
  -d '{
        "id": "id-3",
        "values": [4.0, 2.0],
        "setMetadata": {"type": "comedy"},
        "namespace": "example-namespace"
      }'
curl
{}

POST /vectors/update

  • id (body, string, required) — Vector's unique id.
  • values (body, number[]) — Vector data.
  • sparseValues (body, object) — Vector sparse data. Represented as a list of indices and a list of corresponded values, which must be with the same length.
  • setMetadata (body, object) — Metadata to set for the vector.
  • namespace (body, string) — The namespace containing the vector to update.
  • 200 — A successful response.
  • default — An unexpected error response.
Suggest an edit

Propose a replacement for this page. The site team reviews it before applying any changes.

Export
Documentation menu