sqlitevec

package
v1.9.0 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package sqlitevec stores chunk embedding vectors in the same SQLite database as the document metadata, using the sqlite-vec extension's vec0 virtual table. Search is exact (brute-force) K-nearest-neighbour over unit-normalized vectors, so L2 distance ranks the same as cosine similarity.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func OpenVectorStorage added in v1.7.0

func OpenVectorStorage(ctx context.Context, path string, dimensions int) (storage.VectorStorage, error)

OpenVectorStorage opens the vector store; Open already prepares the schema. It returns the interface so a failure yields a nil storage.VectorStorage, not a typed nil.

Types

type Store

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

func Open

func Open(ctx context.Context, path string, dimensions int) (*Store, error)

Open connects to the SQLite database at path and ensures the vec0 vector table exists. The vectors live in the same file as the documents/chunks tables.

func (*Store) Close

func (s *Store) Close() error

func (*Store) Delete

func (s *Store) Delete(ctx context.Context, chunkIDs []int64) error

func (*Store) EnsureSchema

func (s *Store) EnsureSchema(ctx context.Context) error

EnsureSchema creates the vec0 virtual table if it does not exist. The vector column is a fixed-length float32 list sized to the configured embedding dimensions.

func (*Store) Replace

func (s *Store) Replace(ctx context.Context, embeddings []storage.ChunkEmbedding) error

Replace upserts the given chunk vectors. Existing rows for the same chunk ids are removed first, then the normalized vectors are inserted, all in one transaction.

func (*Store) Search

func (s *Store) Search(ctx context.Context, query []float32, limit int) ([]storage.VectorHit, error)

Search returns the limit nearest chunk vectors to the query, closest first. The query is normalized so that L2 distance ranks the same as cosine similarity.

Jump to

Keyboard shortcuts

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