pgvector

package
v0.7.0 Latest Latest
Warning

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

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

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package pgvector implements vectorstore.VectorStore using PostgreSQL's pgvector extension -- the vector/semantic store's Tier 1, stable backend. A dedicated pool/package rather than folding into internal/state/postgres: the vector extension and its own table are an entirely separate concern from control-plane metadata, opt-in (vector_store must be explicitly configured), and this keeps an existing Postgres-backed deployment that never touches vector_store from ever needing the extension to exist at all.

Index

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 with PostgreSQL + pgvector.

func New

func New(ctx context.Context, dsn string, dimensions int) (*Store, error)

New creates a pgvector-backed store. dimensions fixes the embedding column's width at schema-creation time (pgvector's vector(N) type is fixed-dimension) -- every item upserted must supply exactly this many floats, checked at the API layer before it ever reaches SQL.

func (*Store) Close

func (s *Store) Close() error

func (*Store) Delete

func (s *Store) Delete(ctx context.Context, namespace, id string) error

func (*Store) Downgrade

func (s *Store) Downgrade(ctx context.Context) error

Downgrade rolls back the most recently applied vector migration under the same advisory lock Init uses. Baseline (v1) Down drops vector_items (destructive).

func (*Store) Init

func (s *Store) Init(ctx context.Context) error

Init applies pending numbered schema migrations for vector_items (tracked in vector_schema_migrations, not the state store's schema_migrations). Safe to call concurrently from multiple processes -- wrapped in a session advisory lock like state.Store.Init. The vector extension itself is already created by New.

Known limitation: the embedding column's dimension is fixed the FIRST time the table is created; CREATE TABLE IF NOT EXISTS never revisits it. Changing vector_store.dimensions after the table exists does not migrate rows or the column type -- Upsert fails with a Postgres dimension-mismatch error until the table is dropped/recreated. No in-place ALTER COLUMN TYPE step is registered for that.

func (*Store) Search

func (*Store) Upsert

func (s *Store) Upsert(ctx context.Context, item *models.VectorItem) error

Jump to

Keyboard shortcuts

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