Documentation
¶
Overview ¶
Package pgvec is a vector.Store backed by Postgres with the pgvector extension. The database user must be able to run CREATE EXTENSION vector, or the extension must already be installed.
Each index has a table set of its own, created by the first write; a role that only reads can search an index another role created. A search ranks the chunks of its scope exactly: an approximate (HNSW) index would filter the scope only after collecting its nearest rows of the whole table, so a scope without rows among those would come back short. Text columns sort by byte (COLLATE "C"), the order the other stores use.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Option ¶
type Option func(*options)
Option customizes a Store.
func WithGeneration ¶
WithGeneration keeps the store's tables apart from those of every other generation in the same database, so the vectors of a different embedding model can be built next to the current ones before an application switches over; DropGeneration retires the old ones afterwards. generation is "" (the default) or 1-12 lowercase letters and digits. An index's tables are named ss_<generation>_<hash>_<suffix>, where <hash> is the first 16 hex digits of the SHA-256 of the index, so any index string makes a safe identifier and two indexes never share tables; the default generation's are ss_<hash>_<suffix>, the names the stores used before generations existed.
type Store ¶
Store implements vector.Store on Postgres + pgvector, with one physical table set per index (e.g. a tenant) and generation. It is safe for concurrent use.
func New ¶
New returns a Store using db and ensures the pgvector extension exists. dims must match the embedder's Dimensions(); an index whose tables hold vectors of other dimensions fails with vector.ErrDimensions, and the vectors of another model, whatever their size, belong in another generation (WithGeneration).