qdrant

package
v0.7.3 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2025 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultBatchSize      = 100
	MaxBatchSize          = 1000
	DefaultMaxConcurrency = 8
	DefaultRetryAttempts  = 3
	DefaultRetryDelay     = time.Second
	DefaultMaxRetryDelay  = 30 * time.Second
)

Variables

View Source
var (
	ErrMissingEmbedder       = errors.New("qdrant: embedder is required but not provided")
	ErrMissingCollectionName = errors.New("qdrant: collection name is required")
	ErrInvalidNumDocuments   = errors.New("qdrant: number of documents must be positive")
	ErrConnectionFailed      = errors.New("qdrant: connection failed")
	ErrInvalidURL            = errors.New("qdrant: invalid URL provided")
	ErrCollectionExists      = errors.New("qdrant: collection already exists")
	ErrEmptyQuery            = errors.New("qdrant: query cannot be empty")
	ErrDimensionMismatch     = errors.New("qdrant: vector dimension mismatch")
	ErrBatchSizeTooLarge     = errors.New("qdrant: batch size exceeds maximum allowed")
	ErrPartialBatchFailure   = errors.New("qdrant: some batches failed to process")
)
View Source
var ErrInvalidOptions = errors.New("qdrant: invalid options provided")

Functions

func New

func New(opts ...Option) (vectorstores.VectorStore, error)

Types

type BatchConfig added in v0.2.0

type BatchConfig struct {
	BatchSize      int           `json:"batch_size"`
	MaxConcurrency int           `json:"max_concurrency"`
	RetryAttempts  int           `json:"retry_attempts"`
	RetryDelay     time.Duration `json:"retry_delay"`
	MaxRetryDelay  time.Duration `json:"max_retry_delay"`
}

type BatchResult added in v0.2.0

type BatchResult struct {
	TotalProcessed int           `json:"total_processed"`
	TotalFailed    int           `json:"total_failed"`
	Duration       time.Duration `json:"duration"`
	Errors         []error       `json:"errors,omitempty"`
	ProcessedIDs   []string      `json:"processed_ids,omitempty"`
}

type Option

type Option func(*options)

Option defines a function type for configuring Qdrant store options.

func WithAPIKey

func WithAPIKey(apiKey string) Option

WithAPIKey sets the API key for Qdrant authentication.

func WithBatchSize

func WithBatchSize(size int) Option

WithBatchSize sets the batch size for bulk operations.

func WithCollectionName

func WithCollectionName(name string) Option

WithCollectionName sets the collection name for the Qdrant store.

func WithContentKey

func WithContentKey(contentKey string) Option

WithContentKey sets the key used to store document content in Qdrant payload.

func WithEmbedder

func WithEmbedder(embedder embeddings.Embedder) Option

WithEmbedder sets the embedder for generating vector embeddings.

func WithHost

func WithHost(host string) Option

WithHost sets the Qdrant server host and constructs the URL.

func WithHostAndPort

func WithHostAndPort(host string, port int) Option

WithHostAndPort sets the Qdrant server host and port.

func WithLogger

func WithLogger(logger *slog.Logger) Option

WithLogger sets the logger for the Qdrant store.

func WithRetryAttempts

func WithRetryAttempts(attempts int) Option

WithRetryAttempts sets the number of retry attempts for failed operations.

func WithTLS

func WithTLS(useTLS bool) Option

WithTLS enables or disables TLS for the Qdrant connection.

func WithTimeout

func WithTimeout(timeoutSeconds int) Option

WithTimeout sets the connection timeout in seconds.

func WithURL

func WithURL(qdrantURL url.URL) Option

WithURL sets the Qdrant server URL.

type Store

type Store struct {
	// contains filtered or unexported fields
}

func (*Store) AddDocuments

func (s *Store) AddDocuments(ctx context.Context, docs []schema.Document, options ...vectorstores.Option) ([]string, error)

func (*Store) AddDocumentsBatch added in v0.2.0

func (s *Store) AddDocumentsBatch(
	ctx context.Context,
	docs []schema.Document,
	progressCallback func(processed, total int, duration time.Duration),
	options ...vectorstores.Option,
) ([]string, error)

func (*Store) CreateCollection

func (s *Store) CreateCollection(ctx context.Context, name string, dimension int, options ...vectorstores.Option) error

func (*Store) DeleteCollection

func (s *Store) DeleteCollection(ctx context.Context, name string) error

func (*Store) DeleteDocuments

func (s *Store) DeleteDocuments(ctx context.Context, ids []string, options ...vectorstores.Option) error

func (*Store) DeleteDocumentsByFilter added in v0.6.0

func (s *Store) DeleteDocumentsByFilter(ctx context.Context, filters map[string]any, options ...vectorstores.Option) error

func (*Store) GetBatchConfig added in v0.2.0

func (s *Store) GetBatchConfig() BatchConfig

func (*Store) Health

func (s *Store) Health(ctx context.Context) error

func (*Store) ListCollections

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

func (*Store) SetBatchConfig added in v0.2.0

func (s *Store) SetBatchConfig(config BatchConfig)

func (*Store) SimilaritySearch

func (s *Store) SimilaritySearch(
	ctx context.Context,
	query string,
	numDocuments int,
	options ...vectorstores.Option,
) ([]schema.Document, error)

func (*Store) SimilaritySearchBatch added in v0.7.0

func (s *Store) SimilaritySearchBatch(
	ctx context.Context,
	queries []string,
	numDocuments int,
	options ...vectorstores.Option,
) ([][]schema.Document, error)

func (*Store) SimilaritySearchWithScores

func (s *Store) SimilaritySearchWithScores(
	ctx context.Context,
	query string,
	numDocuments int,
	options ...vectorstores.Option,
) ([]vectorstores.DocumentWithScore, error)

Jump to

Keyboard shortcuts

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