Skip to main content
New projects should use the Documents API. To move an existing index, see Move to the Documents API.
When you split a long source document into chunks, each chunk is stored as its own record in a legacy 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. The code on this page assumes you generate the vectors yourself. For a document index, see Manage document chunks.
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:
Python

Search within a document

To search only one source document’s chunks, add a metadata filter on document_id:
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:
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.
Python