pgvector

package
v0.0.0-...-4821133 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2026 License: MIT Imports: 8 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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Migrate

func Migrate(ctx context.Context, db *sql.DB) error

Migrate runs all pending goose migrations against db.

Types

type PgvectorStore

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

PgvectorStore persists and queries knowledge documents using Postgres + pgvector.

func New

func New(ctx context.Context, dsn string) (*PgvectorStore, error)

New creates a new PgvectorStore connected to the given DSN.

func (*PgvectorStore) Close

func (s *PgvectorStore) Close() error

Close releases the connection pool held by the store.

func (*PgvectorStore) ReplaceProject

func (s *PgvectorStore) ReplaceProject(ctx context.Context, tenantID, projectKey string, docs []knowledge.Document) error

ReplaceProject atomically removes all documents for tenantID+projectKey and inserts docs in a single transaction. On any error the transaction is rolled back.

func (*PgvectorStore) Search

func (s *PgvectorStore) Search(ctx context.Context, queryEmbedding []float32, f knowledge.Filter, topK int) ([]knowledge.Hit, error)

Search returns the topK nearest documents to queryEmbedding filtered by f. Score is cosine similarity (1 - cosine distance), ranging from 0 to 1. If topK is zero or queryEmbedding is empty, an empty slice is returned.

func (*PgvectorStore) Stats

func (s *PgvectorStore) Stats(ctx context.Context, tenantID, projectKey string) (int, error)

Stats returns the number of indexed documents for the given tenantID and project key.

func (*PgvectorStore) Upsert

func (s *PgvectorStore) Upsert(ctx context.Context, docs []knowledge.Document) error

Upsert inserts or updates the given documents in the store. If docs is empty, Upsert returns nil immediately.

Jump to

Keyboard shortcuts

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