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:
- 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.
- 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 ¶
- type Store
- func (s *Store) Close() error
- func (s *Store) CreateCollection(ctx context.Context, name string, dimension int) error
- func (s *Store) Delete(ctx context.Context, collection string, ids []string) error
- func (s *Store) Search(ctx context.Context, collection string, query []float32, topK int, ...) ([]storage.SearchResult, error)
- func (s *Store) Upsert(ctx context.Context, collection string, embeddings []storage.Embedding) error
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 NewWithClient ¶ added in v0.6.0
func NewWithClient(client redis.UniversalClient) *Store
NewWithClient wraps an existing go-redis client (useful for tests / custom opts).