Documentation
¶
Overview ¶
Package vector defines the interface for pluggable vector storage backends.
Index ¶
- type Backend
- type Factory
- type Filter
- type Registry
- func (r *Registry) Fallback() Backend
- func (r *Registry) Get(configID *string) (Backend, error)
- func (r *Registry) GetOrCreate(configID, backendType string, config map[string]any) (Backend, error)
- func (r *Registry) Put(configID string, backend Backend)
- func (r *Registry) RegisterFactory(backendType string, factory Factory)
- func (r *Registry) Remove(configID string)
- type SearchResult
- type StoreItem
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Backend ¶
type Backend interface {
// EmbeddingDimension returns the number of dimensions this backend expects.
EmbeddingDimension() int
// Store persists a chunk's embedding.
Store(ctx context.Context, id string, embedding []float64, metadata map[string]any) error
// Delete removes a chunk's embedding.
Delete(ctx context.Context, id string) error
// Search returns chunk IDs ranked by similarity to the query vector.
Search(ctx context.Context, query []float64, filter Filter, topK int) ([]SearchResult, error)
// StoreBatch persists multiple embeddings.
StoreBatch(ctx context.Context, items []StoreItem) error
// DeleteBatch removes multiple embeddings.
DeleteBatch(ctx context.Context, ids []string) error
// Ping checks backend connectivity.
Ping(ctx context.Context) error
}
Backend is the interface that all vector store implementations must satisfy.
type Filter ¶
type Filter struct {
// ChunkIDs restricts search to specific chunks (used for ACL filtering).
ChunkIDs []string
// Metadata filters on chunk metadata fields.
Metadata map[string]any
}
Filter constrains a similarity search.
type Registry ¶ added in v0.7.0
type Registry struct {
// contains filtered or unexported fields
}
Registry manages lazy-initialized vector backends keyed by config ID. It holds a fallback backend used when no per-topic config is specified.
func NewRegistry ¶ added in v0.7.0
NewRegistry creates a new backend registry with the given fallback backend.
func (*Registry) Get ¶ added in v0.7.0
Get returns a backend for the given config ID. If configID is nil or empty, the fallback backend is returned.
func (*Registry) GetOrCreate ¶ added in v0.7.0
func (r *Registry) GetOrCreate(configID, backendType string, config map[string]any) (Backend, error)
GetOrCreate returns a cached backend for the config ID, or creates one using the registered factory for the given backend type and config map.
func (*Registry) RegisterFactory ¶ added in v0.7.0
RegisterFactory registers a factory for a backend type (e.g. "pgvector", "qdrant").
type SearchResult ¶
SearchResult is a single result from a similarity search.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package pgvector implements the vector.Backend interface using PostgreSQL with pgvector.
|
Package pgvector implements the vector.Backend interface using PostgreSQL with pgvector. |
|
Package vectortest provides a reusable conformance test suite for vector backends.
|
Package vectortest provides a reusable conformance test suite for vector backends. |