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 ¶
- type Store
- func (s *Store) Close() error
- func (s *Store) Delete(ctx context.Context, namespace, id string) error
- func (s *Store) Downgrade(ctx context.Context) 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 with PostgreSQL + pgvector.
func New ¶
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) Downgrade ¶
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 ¶
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 (s *Store) Search(ctx context.Context, req *models.VectorSearchRequest) ([]*models.VectorSearchResult, error)