Documentation
¶
Overview ¶
Package couchbase stores precomputed vectors in an exclusively bound Couchbase collection. StoreConfig.CollectionName derives the physical collection from the declared encoder space and coordinate width. The host provisions this named collection in a chosen bucket and scope; InitializeSchema creates only its primary query index. Construction validates SQL++ VECTOR_DISTANCE.
Upsert admits and encodes the entire batch before the first native KV call. Coordinates retain their float64 values within the native float32 range; cosine additionally requires a positive float64 squared norm. Writes, queries and stored records share those constraints because VECTOR_DISTANCE otherwise returns NULL. Each complete uncompressed JSON value must fit 20 MiB, including metadata, coordinates and escaping. KV keys preserve document IDs up to the named-collection limit of 246 bytes. A write failure reports evidence for acknowledged, uncertain and unattempted IDs.
A primary index is not a vector index. Only QueryByScan and DeleteMatching read the complete collection. Each requires explicit record, byte and time limits. QueryByScan charges each native JSON result row (including CAS and all properties) before decoding or filtering it. Request-plus reads capture records but do not provide a collection-wide snapshot. Rankings use the captured vectors and native distances; conditional deletion verifies each captured CAS. The host owns the SDK cluster. DeleteIDs is an independent KV operation.
Index ¶
- Constants
- type Similarity
- type Store
- func (s *Store) DeleteIDs(ctx context.Context, ids []string) error
- func (s *Store) DeleteMatching(ctx context.Context, predicate filter.Predicate, budget vectorstore.ScanBudget) error
- func (s *Store) QueryByScan(ctx context.Context, request *vectorstore.Query, budget vectorstore.ScanBudget) (*vectorstore.SearchResponse, error)
- func (s *Store) Upsert(ctx context.Context, batch *vectorstore.Batch) error
- type StoreConfig
Constants ¶
const ( DefaultScopeName = "_default" DefaultSimilarity = SimilarityDotProduct )
const Provider = "Couchbase"
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Similarity ¶
type Similarity string
const ( SimilarityCosine Similarity = "COSINE" SimilarityL2Norm Similarity = "L2" SimilarityDotProduct Similarity = "DOT" )
func (Similarity) String ¶
func (s Similarity) String() string
func (Similarity) Valid ¶
func (s Similarity) Valid() bool
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
func (*Store) DeleteMatching ¶ added in v0.59.0
func (s *Store) DeleteMatching(ctx context.Context, predicate filter.Predicate, budget vectorstore.ScanBudget) error
DeleteMatching preflights the entire collection before the first mutation. CAS prevents deletion of a replacement that was never evaluated by Core.
func (*Store) QueryByScan ¶ added in v0.60.0
func (s *Store) QueryByScan(ctx context.Context, request *vectorstore.Query, budget vectorstore.ScanBudget) (*vectorstore.SearchResponse, error)
type StoreConfig ¶
type StoreConfig struct {
Cluster *gocb.Cluster
BucketName string
ScopeName string
Space vectorstore.SpaceID
Dimensions int
Similarity Similarity
// InitializeSchema creates the collection's default primary query index;
// the bucket, scope and collection must already exist.
InitializeSchema bool
}
StoreConfig wires a host-owned SDK cluster and an exclusively managed document collection. The host owns connecting and closing the cluster.
func (StoreConfig) CollectionName ¶
func (s StoreConfig) CollectionName() string
CollectionName returns the actual collection the host must provision in its chosen bucket and scope. Changing coordinate space or width selects another physical collection and cannot mix vectors in an existing one.
func (StoreConfig) Validate ¶
func (s StoreConfig) Validate() error