qdrant

package module
v0.61.0 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2026 License: Apache-2.0 Imports: 16 Imported by: 0

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

Examples

Constants

View Source
const (
	Provider = "Qdrant"

	// SpaceMetadataKey binds the physical collection to an immutable encoder space.
	SpaceMetadataKey = "scope.vector_space"
)

Variables

View Source
var (
	ErrMissingClient         = errors.New("qdrant: Client is required")
	ErrMissingCollectionName = errors.New("qdrant: CollectionName is required")

	ErrInvalidPointID         = errors.New("qdrant: invalid point ID")
	ErrIncompatibleCollection = errors.New("qdrant: incompatible native collection")
)

Functions

This section is empty.

Types

type APIClient added in v0.43.0

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)
	}
}

func (*Store) CheckDocuments added in v0.59.0

func (s *Store) CheckDocuments(ctx context.Context, space vectorstore.SpaceID, docs []*document.Document) error

func (*Store) CheckQuery added in v0.59.0

func (s *Store) CheckQuery(ctx context.Context, space vectorstore.SpaceID, opts vectorstore.SearchOptions) error

func (*Store) DeleteIDs

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

func (*Store) DeleteWhere

func (s *Store) DeleteWhere(ctx context.Context, predicate filter.Predicate) error

func (*Store) Query added in v0.59.0

func (s *Store) Query(ctx context.Context, request *vectorstore.Query) (response *vectorstore.SearchResponse, err error)

func (*Store) Upsert added in v0.59.0

func (s *Store) Upsert(ctx context.Context, batch *vectorstore.Batch) error

type StoreConfig

type StoreConfig struct {
	Client         APIClient
	CollectionName string
	Space          vectorstore.SpaceID
}

func (StoreConfig) Validate

func (s StoreConfig) Validate() error

Jump to

Keyboard shortcuts

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