Skip to main content
When you split a long source document into chunks, each chunk is stored as its own document (in a document index) or record (in a vector index). To work with all of a source document’s chunks at once, give each chunk a structured ID prefixed with the source document’s ID, and a document_id metadata field. Each task shows a document index first, then a vector index. The document-index code assumes a chunk_text field declared with embed for integrated embedding, so Pinecone generates the vectors, and requires API version 2026-07 (Python SDK 10.1.0 or later). The vector-index code assumes you generate the vectors yourself.
Pinecone is eventually consistent, so a read right after a write (upsert, update, or delete) may not return the latest data. If you need to read immediately after writing, add a short delay or retry logic.

Upsert chunks

Upsert each chunk with its structured ID and document_id, plus any other metadata you want to filter on or display. On a document index with integrated embedding, each upsert is capped at 96 documents instead of 1,000:
Python

Search within a document

To search only one source document’s chunks, add a metadata filter on document_id. On a document index, you search with query text and Pinecone embeds it:
Python

Fetch all chunks of a document

To retrieve all of a source document’s chunks, list their IDs by prefix, and then fetch them. On a document index, you can also fetch them by passing a filter such as {"document_id": {"$eq": "document1"}} to documents.fetch, which returns up to 100 matches per page by default (set limit for up to 10,000):
Python

Delete chunks

To delete some or all of a source document’s chunks, filter on their metadata:
Python

Replace a chunked document

When the number or order of a source document’s chunks changes, delete all of its chunks with a metadata filter, and then upsert the new ones. To change one chunk’s content without changing the chunk count, update it by ID instead.
To update most of the data in a large namespace, contact Support about a faster, cheaper approach based on an export.
Python