go-rag/vectorstore.go
Snider d8fd067a8c feat: Phase 3 enhancements — sentence splitting, collection helpers, keyword filter, benchmarks
3.1: Sentence-aware chunk splitting at ". ", "? ", "! " boundaries when
paragraphs exceed ChunkConfig.Size. Overlap now aligns to word boundaries
to avoid mid-word splits.

3.2: VectorStore interface gains ListCollections and CollectionInfo methods.
New collections.go with ListCollections, DeleteCollection, CollectionStats
helpers returning backend-agnostic CollectionInfo. Mock updated accordingly.

3.3: KeywordFilter re-ranks QueryResults by boosting scores for keyword
matches (case-insensitive, +10% per keyword). QueryConfig.Keywords flag
enables automatic extraction and filtering.

3.4: Mock-only benchmarks for chunking, query, ingest, formatting, and
keyword filtering.

Co-Authored-By: Virgil <virgil@lethean.io>
2026-02-20 08:02:00 +00:00

40 lines
1.6 KiB
Go

package rag
import "context"
// VectorStore defines the interface for vector storage and search.
// QdrantClient satisfies this interface.
type VectorStore interface {
// CreateCollection creates a new vector collection with the given
// name and vector dimensionality.
CreateCollection(ctx context.Context, name string, vectorSize uint64) error
// CollectionExists checks whether a collection with the given name exists.
CollectionExists(ctx context.Context, name string) (bool, error)
// DeleteCollection deletes the collection with the given name.
DeleteCollection(ctx context.Context, name string) error
// ListCollections returns all collection names in the store.
ListCollections(ctx context.Context) ([]string, error)
// CollectionInfo returns metadata about a collection. Implementations
// should populate at least PointCount and VectorSize in the returned
// CollectionInfo struct.
CollectionInfo(ctx context.Context, name string) (*CollectionInfo, error)
// UpsertPoints inserts or updates points in the named collection.
UpsertPoints(ctx context.Context, collection string, points []Point) error
// Search performs a vector similarity search, returning up to limit results.
// An optional filter map restricts results by payload field values.
Search(ctx context.Context, collection string, vector []float32, limit uint64, filter map[string]string) ([]SearchResult, error)
}
// CollectionInfo holds backend-agnostic metadata about a collection.
type CollectionInfo struct {
Name string
PointCount uint64
VectorSize uint64
Status string // e.g. "green", "yellow", "red", "unknown"
}