pgstore

package
v0.18.0 Latest Latest
Warning

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

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

Documentation

Overview

Package pgstore implements the shared pgwire execution semantics used by PostgreSQL/pgvector and CockroachDB. Provider packages remain responsible for configuration validation and schema provisioning.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Provider        string
	Pool            *pgxpool.Pool
	SchemaName      string
	TableName       string
	MetadataColumn  string
	EmbeddingModel  embedding.Model
	DocumentBatcher vectorstore.Batcher
	DistanceMetric  DistanceMetric
}

Config contains only shared execution dependencies. Schema policy belongs to the provider package and must be resolved before constructing the engine.

type DistanceMetric

type DistanceMetric string

DistanceMetric selects the pgvector-compatible query operator.

const (
	DistanceCosine DistanceMetric = "cosine"
	DistanceL2     DistanceMetric = "l2"
	DistanceIP     DistanceMetric = "ip"
)

func (DistanceMetric) String

func (d DistanceMetric) String() string

func (DistanceMetric) Valid

func (d DistanceMetric) Valid() bool

type Store

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

Store executes pgvector-compatible data operations for one named provider.

func New

func New(config Config) (Store, error)

New builds the shared PostgreSQL-dialect store that pgvector, CockroachDB, and other wire-compatible backends delegate to. The provider name is passed in so errors name the module the caller actually imported instead of this internal one.

func (*Store) DeleteIDs

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

DeleteIDs removes rows by primary key — `DELETE ... WHERE id = ANY($1)`. pgx maps the []string to a Postgres text array. An empty slice is a no-op; unknown ids are silently ignored (idempotent). Implements vectorstore.IDDeleter.

func (*Store) DeleteWhere

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

func (*Store) Index

func (s *Store) Index(ctx context.Context, request *vectorstore.IndexRequest) (err error)

Index embeds the documents and upserts them into the configured table.

func (*Store) Search

func (s *Store) Search(ctx context.Context, req *vectorstore.SearchRequest) (response *vectorstore.SearchResponse, err error)

Search embeds the query, runs an ANN search, and returns the matching documents above the configured MinScore threshold.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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