Records with integrated embedding, for indexes created with ::pinecone::indexes/create-index-for-model: upsert text and let Pinecone embed it, then search by text (optionally reranked). Pinecone calls this the legacy Records API; it keeps working on API version 2026-07.

Functions

build-search-body

fn (text: Str, options: Map): Map

The Records search body for a text query: query: {inputs: {text}, top_k, filter?} plus the set options among fields and rerank. options: top_k (default 10), filter, fields, rerank ({model, rank_fields, top_n?}). Exposed for testing.

Example

::pinecone::records/build-search-body("what runs workflows?", {top_k: 3})  // {query: {inputs: {text: "what runs workflows?"}, top_k: 3}}

search-records

fn (host: Str, namespace: Str, text: Str): Map
fn (host: Str, namespace: Str, text: Str, options: Map): Map
fn (host: Str, namespace: Str, text: Str, options: Map, opts: Map): Map

POST {host}/records/namespaces/{namespace}/search - Search by text. options as for build-search-body. Returns {result: {hits: [{_id, _score, fields}]}, usage}.

Example

host ::pinecone::indexes/describe-index("docs").host
out ::pinecone::records/search-records(host, "notes", "what runs workflows?", {
  top_k: 5,
  fields: ["chunk_text", "category"],
  rerank: {model: "bge-reranker-v2-m3", rank_fields: ["chunk_text"], top_n: 3}
})
map(out.result.hits, (h) { h.fields.chunk_text })
Context Vars: pinecone.api.key

upsert-records

fn (host: Str, namespace: Str, records: Vec): Any
fn (host: Str, namespace: Str, records: Vec, opts: Map): Any

POST {host}/records/namespaces/{namespace}/upsert - Upsert records (up to 96 per call): each needs an _id and the text field named in the index's field_map; every other field is stored as metadata. Sent as newline-delimited JSON. Use ::pinecone/DEFAULT_NAMESPACE for the default namespace.

Example

host ::pinecone::indexes/describe-index("docs").host
::pinecone::records/upsert-records(host, "notes", [
  {_id: "n1", chunk_text: "Hot runs workflows as code.", category: "docs"},
  {_id: "n2", chunk_text: "Pinecone stores the vectors.", category: "docs"}
])
Context Vars: pinecone.api.key