pinecone

package module
v0.61.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 10, 2026 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Overview

Package pinecone stores and ranks precomputed float32 vectors under an explicit index-space binding. Provision a ready dense serverless index with the SpaceTag tag; the adapter verifies its space, host, dimensions and metric against the native control plane. A model or document batcher is not a store dependency. The Host must coordinate reprovisioning across control/data RPCs.

Each upsert writes the original content, the lossless metadata_json, and the scalar keyword projection metadata_terms together. Reindex older two-field records. Query and DeleteWhere support native top-level scalar string equality; all other filters fail explicitly, without listing or fetching the namespace. No cross-RPC snapshot or search-visibility guarantee is implied. Native service limits and errors remain visible.

Upsert validates all records before publishing any. Its native groups each contain at most MaxVectorsPerUpsert entries and fit a conservative 2,000,000-byte protobuf request budget, including the namespace and message envelopes. A record that cannot fit alone fails before any group is published. CheckDocuments and Upsert also enforce a conservative 40,000-byte budget on each complete protobuf metadata Struct, including content, metadata_json, metadata_terms and framing. This adapter admission measure does not claim to reproduce the service's unpublished metadata accounting. On failure vectorstore.WriteError distinguishes acknowledged IDs, unconfirmed IDs with a possible count-only acknowledgment, and unattempted groups. It never guesses which IDs in a partial acknowledgment succeeded. Native acknowledgments do not imply that an eventually consistent query can already see a record.

The constructor opens and owns the data connection, not the supplied control client. Default tests run against offline protocol fixtures. Tagged tests need explicitly provisioned Local or cloud indexes with the requested space; their namespaces are isolated.

Index

Examples

Constants

View Source
const (
	Provider = "Pinecone"

	MaxTopK = 10000

	// SpaceTag is the native index tag provisioning must bind to the encoder space.
	SpaceTag = "scope_vector_space"
)
View Source
const (
	MaxVectorsPerUpsert = 1000
)

Variables

View Source
var (
	ErrMissingClient    = errors.New("pinecone: Client is required")
	ErrMissingIndexName = errors.New("pinecone: IndexName is required")

	ErrIncompatibleIndex = errors.New("pinecone: native index is incompatible")
)

Functions

This section is empty.

Types

type APIClient added in v0.43.0

type APIClient interface {
	DescribeIndex(context.Context, string) (*pineconesdk.Index, error)
	Index(pineconesdk.NewIndexConnParams, ...grpc.DialOption) (*pineconesdk.IndexConnection, error)
}

APIClient reads authoritative native index policy and opens a native data connection. The host owns credentials, transport policy and client lifetime; Store owns and closes the connection it opens.

type Store

type Store struct {
	// contains filtered or unexported fields
}

func NewStore

func NewStore(ctx context.Context, config StoreConfig) (*Store, error)
Example
package main

import (
	"context"
	"os"

	"time"

	pineconesdk "github.com/pinecone-io/go-pinecone/v7/pinecone"

	"github.com/Tangerg/scope/core/document"

	"github.com/Tangerg/scope/core/vectorstore"
	"github.com/Tangerg/scope/vectorstores/pinecone"
)

func main() {
	ctx, cancel := context.WithTimeout(context.Background(), time.Minute)
	defer cancel()
	client, err := pineconesdk.NewClient(pineconesdk.NewClientParams{ApiKey: os.Getenv("PINECONE_API_KEY")})
	if err != nil {
		panic(err)
	}
	// The host provisions a ready 2-dimensional dense serverless index once.
	store, err := pinecone.NewStore(ctx, pinecone.StoreConfig{Client: client, IndexName: os.Getenv("PINECONE_INDEX_NAME"), Namespace: "documents", Space: "example-v1"})
	if err != nil {
		panic(err)
	}
	defer func() {
		if closeErr := store.Close(); closeErr != nil {
			panic(closeErr)
		}
	}()
	if err = store.Upsert(ctx, &vectorstore.Batch{Space: "example-v1", Records: []vectorstore.Record{{Document: &document.Document{ID: "one", Text: "example"}, Values: []float64{1, 0}}}}); err != nil {
		panic(err)
	}
	if _, err = store.Query(ctx, &vectorstore.Query{Space: "example-v1", Values: []float64{1, 0}}); err != nil {
		panic(err)
	}
	if err = store.DeleteIDs(ctx, []string{"one"}); err != nil {
		panic(err)
	}
}

func (*Store) CheckDocuments added in v0.59.0

func (s *Store) CheckDocuments(ctx context.Context, space vectorstore.SpaceID, docs []*document.Document) error

func (*Store) CheckQuery added in v0.59.0

func (s *Store) CheckQuery(ctx context.Context, space vectorstore.SpaceID, opts vectorstore.SearchOptions) error

func (*Store) Close

func (s *Store) Close() error

func (*Store) DeleteIDs

func (s *Store) DeleteIDs(ctx context.Context, ids []string) error

func (*Store) DeleteWhere

func (s *Store) DeleteWhere(ctx context.Context, predicate filter.Predicate) error

func (*Store) Query added in v0.59.0

func (s *Store) Query(ctx context.Context, request *vectorstore.Query) (response *vectorstore.SearchResponse, err error)

func (*Store) Upsert added in v0.59.0

func (s *Store) Upsert(ctx context.Context, batch *vectorstore.Batch) error

type StoreConfig

type StoreConfig struct {
	Client    APIClient
	IndexName string
	Namespace string
	Space     vectorstore.SpaceID
}

func (StoreConfig) Validate

func (s StoreConfig) Validate() error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL