Skip to main content
POST
/
vectors
/
update
# 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"
)
// 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: {
    genre: "comedy",
  },
});
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("genre",
					Value.newBuilder().setStringValue("comedy").build())
			.build();
        UpdateResponse updateResponse = index.update("id-3", values, metaData, "example-namespace", null, null);
        System.out.println(updateResponse);
    }
}
package main

import (
    "context"
    "log"

    "github.com/pinecone-io/go-pinecone/v2/pinecone"
    "google.golang.org/protobuf/types/known/structpb"
)

func main() {
    ctx := context.Background()

    pc, err := pinecone.NewClient(pinecone.NewClientParams{
        ApiKey: "YOUR_API_KEY",
    })
    if err != nil {
        log.Fatalf("Failed to create Client: %v", err)
    }

    idx, err := pc.DescribeIndex(ctx, "docs-example")
    if err != nil {
        log.Fatalf("Failed to describe index \"%v\": %v", idx.Name, err)
    }

    idxConnection, err := pc.Index(pinecone.NewIndexConnParams{Host: idx.Host, Namespace: "example-namespace"})
    if err != nil {
        log.Fatalf("Failed to create IndexConnection for Host %v: %v", idx.Host, err)
    }

    id := "id-3"

    metadataMap := map[string]interface{}{
        "genre": "comedy",
    }

    metadataFilter, err := structpb.NewStruct(metadataMap)
    if err != nil {
        log.Fatalf("Failed to create metadata map: %v", err)
    }

    err = idxConnection.UpdateVector(ctx, &pinecone.UpdateVectorRequest{
        Id:       id,
        Metadata: metadataFilter,
    })
    if err != nil {
        log.Fatalf("Failed to update vector with ID %v: %v", id, err)
    }
}
using Pinecone;

var pinecone = new PineconeClient("YOUR_API_KEY");

var index = pinecone.Index("docs-example");

var updateResponse = await index.UpdateAsync(new UpdateRequest {
    Id = "id-3",
    Values = new[] { 4.0f, 2.0f },
    SetMetadata = new Metadata { ["genre"] = "comedy" },
    Namespace = "example-namespace",
});
# 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-07" \
  -d '{
        "id": "id-3",
        "values": [4.0, 2.0],
        "setMetadata": {"genre": "comedy"},
        "namespace": "example-namespace"
      }'
{}
# 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"
)
// 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: {
    genre: "comedy",
  },
});
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("genre",
					Value.newBuilder().setStringValue("comedy").build())
			.build();
        UpdateResponse updateResponse = index.update("id-3", values, metaData, "example-namespace", null, null);
        System.out.println(updateResponse);
    }
}
package main

import (
    "context"
    "log"

    "github.com/pinecone-io/go-pinecone/v2/pinecone"
    "google.golang.org/protobuf/types/known/structpb"
)

func main() {
    ctx := context.Background()

    pc, err := pinecone.NewClient(pinecone.NewClientParams{
        ApiKey: "YOUR_API_KEY",
    })
    if err != nil {
        log.Fatalf("Failed to create Client: %v", err)
    }

    idx, err := pc.DescribeIndex(ctx, "docs-example")
    if err != nil {
        log.Fatalf("Failed to describe index \"%v\": %v", idx.Name, err)
    }

    idxConnection, err := pc.Index(pinecone.NewIndexConnParams{Host: idx.Host, Namespace: "example-namespace"})
    if err != nil {
        log.Fatalf("Failed to create IndexConnection for Host %v: %v", idx.Host, err)
    }

    id := "id-3"

    metadataMap := map[string]interface{}{
        "genre": "comedy",
    }

    metadataFilter, err := structpb.NewStruct(metadataMap)
    if err != nil {
        log.Fatalf("Failed to create metadata map: %v", err)
    }

    err = idxConnection.UpdateVector(ctx, &pinecone.UpdateVectorRequest{
        Id:       id,
        Metadata: metadataFilter,
    })
    if err != nil {
        log.Fatalf("Failed to update vector with ID %v: %v", id, err)
    }
}
using Pinecone;

var pinecone = new PineconeClient("YOUR_API_KEY");

var index = pinecone.Index("docs-example");

var updateResponse = await index.UpdateAsync(new UpdateRequest {
    Id = "id-3",
    Values = new[] { 4.0f, 2.0f },
    SetMetadata = new Metadata { ["genre"] = "comedy" },
    Namespace = "example-namespace",
});
# 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-07" \
  -d '{
        "id": "id-3",
        "values": [4.0, 2.0],
        "setMetadata": {"genre": "comedy"},
        "namespace": "example-namespace"
      }'
{}

Authorizations

Api-Key
string
header
required

An API Key is required to call Pinecone APIs. Get yours from the console.

Body

application/json

The request for the update operation.

id
string
required

Vector's unique id.

Required string length: 1 - 512
Example:

"example-vector-1"

values
number<float>[]

Vector data.

Example:
[0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8]
sparseValues
object

Vector sparse data. Represented as a list of indices and a list of corresponded values, which must be with the same length.

setMetadata
object

Metadata to set for the vector.

Example:
{ "genre": "documentary", "year": 2019 }
namespace
string

The namespace containing the vector to update.

Example:

"example-namespace"

Response

A successful response.

The response for the update operation.