vector

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2026 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Overview

Package vector defines the interface for pluggable vector storage backends.

Index

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 SearchResult

type SearchResult struct {
	ChunkID string
	Score   float64
}

SearchResult is a single result from a similarity search.

type StoreItem

type StoreItem struct {
	ID        string
	Embedding []float64
	Metadata  map[string]any
}

StoreItem represents a single embedding to store in a batch operation.

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.

Jump to

Keyboard shortcuts

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