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. usage.egressBytes is the billed size of the response in bytes, when the
server reports it.
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, usage information, and
pagination.next when another page is available. usage.egressBytes is the billed size of the
response in bytes, when the server reports it.
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. To search a
string field with integrated embedding, pass the query as text in an embed or
sparse_embed clause, such as { type: 'embed', field: 'body', query: 'trail running' },
and Pinecone embeds it with the field's model. A dense_vector, sparse_vector,
embed, or sparse_embed clause must appear alone in scoreBy; text and
query_string clauses can be combined.
Naming a field declared with storeText: false in includeFields is rejected with a
400, since its text is not stored; ['*'] leaves such fields out.
Scoring methods in scoreBy, the result count topK, and optional filters
and returned fields.
Ranked matches, the namespace, and usage information. usage.embedTotalTokens
counts the query tokens Pinecone embedded, when the server reports it. usage.egressBytes is
the billed size of the response in bytes, when the server reports it.
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 to search a legacy integrated index; 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. On an index with
integrated embedding, usage.embedTotalTokens counts the tokens Pinecone embedded for the
update; usage is omitted when the request embedded nothing.
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. On an index with integrated
embedding, usage.embedTotalTokens counts the tokens Pinecone embedded for the write;
usage is omitted when the request embedded nothing.
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; IntegratedEmbeddingStringField to have Pinecone embed a field's text; Index.upsertRecords to write to a legacy integrated index.
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