Documentation
¶
Overview ¶
Package pinecone implements vectorstore.VectorStore using Pinecone's REST API. Closes the last remaining "Tier 2, not yet built" vector backend -- see internal/vectorstore/qdrant's package doc for the shared design principles (plain HTTP rather than a generated client, no vendored SDK for a small documented surface) this package follows too, though Pinecone's own shape differs enough from Qdrant/Weaviate that several of their specific conventions don't carry over -- see below.
Pinecone splits its API into a control plane (index lifecycle: create/describe/delete -- always at one fixed host) and a data plane (vectors/upsert, query, vectors/delete -- served at a PER-INDEX host only known after the index is created or described). Init resolves and caches that per-index host once; every data-plane call after that reuses it directly rather than re-resolving on every request.
Unlike Qdrant and Weaviate, Pinecone needs neither a derived UUID point/object ID nor a JSON-encoded metadata workaround: vector IDs accept arbitrary strings, and metadata is natively a freeform key-value object (any type, no schema declaration), so a caller's Metadata map is stored directly rather than serialized into a single blob field. Pinecone also has first-class namespaces as a real partitioning primitive (unlike Qdrant/Weaviate, where "namespace" is just another payload/property field this package invented) -- a caller's Namespace maps directly onto Pinecone's own namespace parameter, not onto a metadata field. tenant_id still goes into metadata and into every query's filter (there's no second dimension of Pinecone-native partitioning to spend on it), and a vector's ID is tenantID+"\x00"+item.ID -- namespaces alone aren't enough to keep two tenants' same-namespace, same-id items from colliding, since both would otherwise map to the exact same (namespace, id) pair.
One consequence of a genuinely freeform, natively-queryable metadata object: Search's Filter is pushed straight into Pinecone's own "$eq"-based filter alongside the tenant_id scope, unlike Weaviate's over-fetch-then-filter-in-Go workaround -- Pinecone can filter inside its own metadata object natively, there's no JSON-blob-string problem here to work around.
Index ¶
- type Store
- func (s *Store) Close() error
- func (s *Store) Delete(ctx context.Context, namespace, id string) error
- func (s *Store) Init(ctx context.Context) error
- func (s *Store) Search(ctx context.Context, req *models.VectorSearchRequest) ([]*models.VectorSearchResult, error)
- func (s *Store) Upsert(ctx context.Context, item *models.VectorItem) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store implements vectorstore.VectorStore against a Pinecone index.
func New ¶
func New(controlURL, apiKey, indexName string, dimensions int, cloud, region string) (*Store, error)
New creates a Pinecone-backed store. apiKey is sent on every request but is ignored entirely by Pinecone Local (any value works there, per Pinecone's own docs) -- a real Pinecone account requires a real key. cloud/region only matter for a real serverless index's actual placement; Pinecone Local accepts (and ignores) any value here too, but the field is structurally required by the create-index request either way. Both default to "aws"/"us-east-1" (Pinecone's own documented example values) if left empty.
func (*Store) Init ¶
Init resolves and caches this store's per-index data-plane host, creating the index first if it doesn't already exist. Safe to call on every startup -- a 404 from describe is treated as "doesn't exist yet, create it," anything else describe returns (including a successful 200) is treated as already there. Intentionally create-if-missing (not a numbered migration trail like pgvector): Pinecone indexes have no evolvable DDL beyond create/describe.
Known limitation, same shape as pgvector's/Qdrant's/Weaviate's: the index's dimension is fixed the first time it's actually created. Changing vector_store.dimensions in langgraph.json after the index already exists does not migrate it -- Upsert/Search start failing loudly with Pinecone's own dimension-mismatch error until the index is manually deleted or recreated at the new width.
func (*Store) Search ¶
func (s *Store) Search(ctx context.Context, req *models.VectorSearchRequest) ([]*models.VectorSearchResult, error)
func (*Store) Upsert ¶
Upsert is a true upsert in one round trip -- Pinecone's own vectors/upsert contract overwrites an existing ID's record entirely, unlike Weaviate (needing delete-then-create) or Qdrant's own insert-vs-update ambiguity. Same known, stated limitation as both of those regardless: created_at is set to "now" on every call, including re-indexing an already-existing id, since there's no partial-update path here either without a read before every write.