Delete schema-based documents by IDs, filter, or an entire namespace.
deleteAll: true removes all documents in this client's namespace.
Exactly one of non-empty ids, filter, or deleteAll: true.
The number of documents matched by the request in matchedRecords.
Errors.PineconeArgumentError when the selection is missing or invalid.
import { Pinecone } from '@pinecone-database/pinecone';
const pc = new Pinecone();
const index = pc.index({ name: 'product-documents', namespace: 'products-en' });
const result = await index.documents.delete({ ids: ['trail-shoe-42'] });
console.log(result.matchedRecords);
Index.deleteMany for vector records.
Fetch schema-based documents by IDs or a metadata filter.
Fetching by filter returns one page at a time.
Either non-empty ids or filter; use paginationToken only with a filter.
Documents keyed by ID in documents, the namespace, usage, and a continuation token
when available.
Errors.PineconeArgumentError when the selection is missing or invalid, or pagination is requested without a filter.
import { Pinecone } from '@pinecone-database/pinecone';
const pc = new Pinecone();
const index = pc.index({ name: 'product-documents', namespace: 'products-en' });
const result = await index.documents.fetch({ ids: ['trail-shoe-42'] });
console.log(result.documents['trail-shoe-42']);
Documents.list to list document IDs; Index.fetch for vector records.
List one page of document IDs in the targeted namespace.
An optional ID prefix, page size, and continuation token; defaults to the first unfiltered page.
Document entries in documents, ordered by ID, and pagination.next when another
page is available.
Errors.PineconeArgumentError when limit is less than 1.
import { Pinecone } from '@pinecone-database/pinecone';
const pc = new Pinecone();
const index = pc.index({ name: 'product-documents', namespace: 'products-en' });
const page = await index.documents.list({ prefix: 'trail-shoe-' });
console.log(page.documents);
Documents.fetch to retrieve document fields; Index.listPaginated for vector record IDs.
Search schema-based documents using one or more scoring methods.
Choose scoring fields and methods supported by your index schema.
Scoring methods in scoreBy, the result count topK, and optional filters
and returned fields.
Ranked matches, the namespace, and usage information.
Errors.PineconeArgumentError when scoreBy is missing or empty, or topK is
missing or less than 1.
import { Pinecone } from '@pinecone-database/pinecone';
const pc = new Pinecone();
const index = pc.index({ name: 'product-documents', namespace: 'products-en' });
const result = await index.documents.search({
scoreBy: [{ type: 'text', fields: ['title'], query: 'hiking shoes' }],
topK: 5, includeFields: ['title'],
});
console.log(result.matches);
Index.searchRecords for integrated embedding search; Index.query for vector similarity queries.
Partially update schema-based documents selected by IDs or a filter.
Unspecified fields are preserved. The example changes category while retaining the document's
title and other fields.
Per-ID changes in documents, or a filter with non-empty setFields and/or
removeFields.
The number of documents matched by the request in matchedRecords.
Errors.PineconeArgumentError when the selection or field changes are missing or incompatible.
import { Pinecone } from '@pinecone-database/pinecone';
const pc = new Pinecone();
const index = pc.index({ name: 'product-documents', namespace: 'products-en' });
await index.documents.update({
documents: [{ _id: 'trail-shoe-42', category: 'hiking-footwear' }],
});
Documents.upsert to write documents; Index.update for vector records.
Write documents to a schema-based index.
A non-empty documents array; each document needs _id and fields matching
the index schema.
The number of documents written in upsertedCount.
Errors.PineconeArgumentError when documents is empty or missing.
import { Pinecone } from '@pinecone-database/pinecone';
const pc = new Pinecone();
const index = pc.index({ name: 'product-documents', namespace: 'products-en' });
const result = await index.documents.upsert({
documents: [{ _id: 'trail-shoe-42', title: 'Waterproof hiking shoe', category: 'footwear' }],
});
console.log(result.upsertedCount);
Documents.update for partial changes; Index.upsertRecords for integrated embedding records.
Read and write documents whose fields follow a schema-based index's schema. Access through Index.documents; do not construct this client directly. Unlike vector operations on Index, these operations work with document fields and scoring methods.
Example