redisvector

package
v0.12.1 Latest Latest
Warning

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

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

Documentation

Overview

Package redisvector provides a Redis-backed VectorStore adapter using the RediSearch module (Redis Stack) for KNN vector similarity search.

It is built on the official go-redis client (github.com/redis/go-redis/v9). The previous hand-rolled TCP implementation had two fatal correctness bugs:

  1. It read replies with a single 64KB net.Conn.Read, so any FT.SEARCH result larger than 64KB (trivial with vectors/metadata) was silently truncated and mis-parsed.
  2. It encoded vectors as a comma-separated ASCII string ("0.1,0.2,..."), but RediSearch VECTOR fields and the KNN $BLOB parameter require raw little-endian float32 bytes. The old adapter could never return a correct match against a real RediSearch index.

This rewrite delegates framing to go-redis and encodes vectors as binary float32 blobs. RESP2 is forced (Protocol: 2) so FT.SEARCH replies have the stable positional array shape that parseSearchReply understands.

Testing note

RediSearch (FT.*) is a Redis module and is NOT emulated by miniredis, so the unit tests here cover the pure, wire-critical logic: binary vector encoding, search-query construction, and reply parsing. End-to-end coverage requires a live Redis Stack instance; set REDISVECTOR_ADDR to run TestIntegration.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Store

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

Store implements storage.VectorStore using Redis with RediSearch.

func New

func New(addr string) (*Store, error)

New creates a RediSearch-backed vector store and verifies connectivity.

func NewWithClient added in v0.6.0

func NewWithClient(client redis.UniversalClient) *Store

NewWithClient wraps an existing go-redis client (useful for tests / custom opts).

func (*Store) Close

func (s *Store) Close() error

func (*Store) CreateCollection

func (s *Store) CreateCollection(ctx context.Context, name string, dimension int) error

func (*Store) Delete

func (s *Store) Delete(ctx context.Context, collection string, ids []string) error

func (*Store) Search

func (s *Store) Search(ctx context.Context, collection string, query []float32, topK int, opts ...storage.SearchOption) ([]storage.SearchResult, error)

func (*Store) Upsert

func (s *Store) Upsert(ctx context.Context, collection string, embeddings []storage.Embedding) error

Jump to

Keyboard shortcuts

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