Skip to main content
New projects should use the Documents API. To move an existing index, see Move to the Documents API.
This page shows you how to upsert records into a namespace in a legacy vector index with the legacy Vectors API. For a document index, see Upsert data. If a record ID already exists, upserting overwrites the entire record. To change only part of a record, update it.

Upsert dense vectors

To upsert dense vectors into an index of dense vectors, use the Upsert records operation:
  • Specify the namespace to upsert into. If the namespace doesn’t exist, it’s created. To use the default namespace, set the namespace to "__default__".
  • Format your input data as records, each with the following:
    • An id field with a unique record identifier for the index namespace.
    • A values field with the dense vector values.
    • Optionally, a metadata field with key-value pairs to store additional information or context. When you query the index, you can use metadata to filter search results.

Upsert sparse vectors

To upsert sparse vectors into an index of sparse vectors, use the Upsert records operation:
  • Specify the namespace to upsert into. If the namespace doesn’t exist, it’s created. To use the default namespace, set the namespace to "__default__".
  • Format your input data as records, each with the following:
    • An id field with a unique record identifier for the index namespace.
    • A sparse_values field with the sparse vector values and indices.
    • Optionally, a metadata field with key-value pairs to store additional information or context. When you query the index, you can use metadata to filter search results.
For example, the following code upserts sparse vector representations of sentences related to the term “apple”, with the source text and additional fields stored as metadata:

Upsert in batches

To control costs when ingesting large datasets (10,000,000+ records), use import instead of upsert.
Send upserts in batches to help increase throughput. A batch should be as large as possible (up to 1,000 records) without exceeding the max request size of 2 MB. The number of records that fit in one batch depends on the vector dimension and metadata size:

Upsert in parallel

Python SDK v6.0.0 and later provide async methods for use with asyncio. Asyncio support lets you use Pinecone with async web frameworks such as FastAPI, Quart, and Sanic. For details, see Async requests.
Send multiple upserts in parallel to help increase throughput. Each upsert call blocks until the response arrives, so send several at once. Upserts can be made asynchronously:

Python SDK with gRPC

The Python SDK with gRPC can upsert faster. Unlike REST, gRPC multiplexes requests, so it handles many requests in parallel without head-of-line blocking. You can also pass retry strategies to the gRPC SDK, including exponential backoff. The gRPC client supports legacy vector indexes only. gRPC support is included in the base pinecone package, and upsert, query, fetch, and delete use the same syntax as the standard SDK. To use it, import the pinecone.grpc subpackage and target an index as usual:
Python
To send multiple upserts in parallel, use upsert_async, which returns a future for each request:
Python
Upserts through the gRPC SDK can hit write throttling sooner. If this happens often, implement retry logic with exponential backoff.

Upsert limits

The limit for text is lower because Pinecone converts that text to vectors at upsert time with integrated embedding, and 96 is the max batch size of the hosted embedding models doing the conversion. The 40 KB filterable metadata limit doesn’t apply to full_text_search text fields.