Documentation
¶
Overview ¶
Package qdrant stores and ranks precomputed coordinates in one concrete native collection. Provision one unnamed dense float32 vector and place its immutable encoder space ID in the collection metadata under SpaceMetadataKey. Width, metric and space are checked against the native collection; the Host must coordinate reprovisioning because schema checks and point RPCs are separate.
A complete point owns its native ID, text and lossless metadata_json. The metadata_terms keyword array is derived in the same write and has no independent write API. Provision a keyword payload index on metadata_terms when required by native indexing policy. Previously stored two-field payloads need reindexing.
Top-level string equality/inequality, null tests and their Boolean combinations are compiled into native conditions before global TopK. Scalar strings remain distinct from arrays, missing keys and null. Other expressions (including numeric ordering and positional array access) return vectorstore.ErrUnsupportedFilter; neither Query nor DeleteWhere enumerates the collection. Returned rows are checked against canonical metadata rather than filtered after TopK. Writes validate the entire batch, request native wait-for-application and preserve unconfirmed identities if a definitive acknowledgment is lost. The Host owns the client and controls direct access to this physical collection.
Index ¶
- Constants
- Variables
- type APIClient
- type Store
- func (s *Store) CheckDocuments(ctx context.Context, space vectorstore.SpaceID, docs []*document.Document) error
- func (s *Store) CheckQuery(ctx context.Context, space vectorstore.SpaceID, opts vectorstore.SearchOptions) error
- func (s *Store) DeleteIDs(ctx context.Context, ids []string) error
- func (s *Store) DeleteWhere(ctx context.Context, predicate filter.Predicate) error
- func (s *Store) Query(ctx context.Context, request *vectorstore.Query) (response *vectorstore.SearchResponse, err error)
- func (s *Store) Upsert(ctx context.Context, batch *vectorstore.Batch) error
- type StoreConfig
Examples ¶
Constants ¶
const ( Provider = "Qdrant" // SpaceMetadataKey binds the physical collection to an immutable encoder space. SpaceMetadataKey = "scope.vector_space" )
Variables ¶
Functions ¶
This section is empty.
Types ¶
type APIClient ¶ added in v0.43.0
type APIClient interface {
ListCollections(context.Context) ([]string, error)
GetCollectionInfo(context.Context, string) (*qdrantclient.CollectionInfo, error)
Upsert(context.Context, *qdrantclient.UpsertPoints) (*qdrantclient.UpdateResult, error)
Query(context.Context, *qdrantclient.QueryPoints) ([]*qdrantclient.ScoredPoint, error)
Delete(context.Context, *qdrantclient.DeletePoints) (*qdrantclient.UpdateResult, error)
}
APIClient exposes the native operations Store consumes. The host owns the client, authentication, transport and collection provisioning.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
func NewStore ¶
func NewStore(ctx context.Context, config StoreConfig) (*Store, error)
Example ¶
package main
import (
"context"
"os"
"time"
qdrantclient "github.com/qdrant/go-client/qdrant"
"github.com/Tangerg/scope/core/document"
"github.com/Tangerg/scope/core/vectorstore"
"github.com/Tangerg/scope/vectorstores/qdrant"
)
func main() {
ctx, cancel := context.WithTimeout(context.Background(), time.Minute)
defer cancel()
client, err := qdrantclient.NewClient(&qdrantclient.Config{Host: os.Getenv("QDRANT_HOST"), APIKey: os.Getenv("QDRANT_API_KEY")})
if err != nil {
panic(err)
}
defer func() {
if closeErr := client.Close(); closeErr != nil {
panic(closeErr)
}
}()
// The host provisions one unnamed FLOAT32 vector through the native API.
if err = client.CreateCollection(ctx, &qdrantclient.CreateCollection{CollectionName: "documents", Metadata: map[string]*qdrantclient.Value{qdrant.SpaceMetadataKey: qdrantclient.NewValueString("example-v1")}, VectorsConfig: qdrantclient.NewVectorsConfig(&qdrantclient.VectorParams{Size: 2, Distance: qdrantclient.Distance_Cosine})}); err != nil {
panic(err)
}
store, err := qdrant.NewStore(ctx, qdrant.StoreConfig{Client: client, CollectionName: "documents", Space: "example-v1"})
if err != nil {
panic(err)
}
if err = store.Upsert(ctx, &vectorstore.Batch{Space: "example-v1", Records: []vectorstore.Record{{Document: &document.Document{ID: "1", Text: "example"}, Values: []float64{1, 0}}}}); err != nil {
panic(err)
}
if _, err = store.Query(ctx, &vectorstore.Query{Space: "example-v1", Values: []float64{1, 0}}); err != nil {
panic(err)
}
if err = store.DeleteIDs(ctx, []string{"1"}); err != nil {
panic(err)
}
}
Output:
func (*Store) CheckDocuments ¶ added in v0.59.0
func (*Store) CheckQuery ¶ added in v0.59.0
func (s *Store) CheckQuery(ctx context.Context, space vectorstore.SpaceID, opts vectorstore.SearchOptions) error
func (*Store) DeleteWhere ¶
func (*Store) Query ¶ added in v0.59.0
func (s *Store) Query(ctx context.Context, request *vectorstore.Query) (response *vectorstore.SearchResponse, err error)
type StoreConfig ¶
type StoreConfig struct {
Client APIClient
CollectionName string
Space vectorstore.SpaceID
}
func (StoreConfig) Validate ¶
func (s StoreConfig) Validate() error