Documentation
¶
Index ¶
- Constants
- Variables
- func New(opts ...Option) (vectorstores.VectorStore, error)
- type BatchConfig
- type BatchResult
- type Option
- func WithAPIKey(apiKey string) Option
- func WithBatchSize(size int) Option
- func WithCollectionName(name string) Option
- func WithContentKey(contentKey string) Option
- func WithEmbedder(embedder embeddings.Embedder) Option
- func WithHost(host string) Option
- func WithHostAndPort(host string, port int) Option
- func WithLogger(logger *slog.Logger) Option
- func WithRetryAttempts(attempts int) Option
- func WithTLS(useTLS bool) Option
- func WithTimeout(timeoutSeconds int) Option
- func WithURL(qdrantURL url.URL) Option
- type Store
- func (s *Store) AddDocuments(ctx context.Context, docs []schema.Document, options ...vectorstores.Option) ([]string, error)
- func (s *Store) AddDocumentsBatch(ctx context.Context, docs []schema.Document, ...) ([]string, error)
- func (s *Store) BatchDeleteDocuments(ctx context.Context, ids []string, progressCallback func(processed, total int), ...) error
- func (s *Store) CreateCollection(ctx context.Context, name string, dimension int, ...) error
- func (s *Store) DeleteCollection(ctx context.Context, name string) error
- func (s *Store) DeleteDocuments(ctx context.Context, ids []string, options ...vectorstores.Option) error
- func (s *Store) GetBatchConfig() BatchConfig
- func (s *Store) GetBatchStats(ctx context.Context, collectionName string) (map[string]interface{}, error)
- func (s *Store) Health(ctx context.Context) error
- func (s *Store) ListCollections(ctx context.Context) ([]string, error)
- func (s *Store) SetBatchConfig(config BatchConfig)
- func (s *Store) SimilaritySearch(ctx context.Context, query string, numDocuments int, ...) ([]schema.Document, error)
- func (s *Store) SimilaritySearchWithScores(ctx context.Context, query string, numDocuments int, ...) ([]vectorstores.DocumentWithScore, error)
Constants ¶
const ( DefaultBatchSize = 100 // Default batch size for operations MaxBatchSize = 1000 // Maximum batch size DefaultMaxConcurrency = 5 // Default concurrent batch workers DefaultRetryAttempts = 3 // Default retry attempts for failed batches DefaultRetryDelay = time.Second DefaultMaxRetryDelay = 30 * time.Second )
Batch configuration constants
Variables ¶
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") )
Enhanced errors
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"`
ParallelEmbed bool `json:"parallel_embed"`
}
BatchConfig holds configuration for batch operations
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"`
}
BatchResult contains the results of a batch operation
type Option ¶
type Option func(*options)
Option defines a function type for configuring Qdrant store options.
func WithAPIKey ¶
WithAPIKey sets the API key for Qdrant authentication.
func WithBatchSize ¶
WithBatchSize sets the batch size for bulk operations.
func WithCollectionName ¶
WithCollectionName sets the collection name for the Qdrant store.
func WithContentKey ¶
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 WithHostAndPort ¶
WithHostAndPort sets the Qdrant server host and port.
func WithLogger ¶
WithLogger sets the logger for the Qdrant store.
func WithRetryAttempts ¶
WithRetryAttempts sets the number of retry attempts for failed operations.
func WithTimeout ¶
WithTimeout sets the connection timeout in seconds.
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)
AddDocuments with enhanced batch processing
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)
AddDocumentsBatch provides comprehensive batch document insertion with progress tracking
func (*Store) BatchDeleteDocuments ¶ added in v0.2.0
func (s *Store) BatchDeleteDocuments( ctx context.Context, ids []string, progressCallback func(processed, total int), options ...vectorstores.Option, ) error
BatchDeleteDocuments provides efficient batch deletion
func (*Store) CreateCollection ¶
func (s *Store) CreateCollection(ctx context.Context, name string, dimension int, options ...vectorstores.Option) error
CreateCollection creates a new collection with specified parameters.
func (*Store) DeleteCollection ¶
DeleteCollection removes a collection and all its data.
func (*Store) DeleteDocuments ¶
func (s *Store) DeleteDocuments(ctx context.Context, ids []string, options ...vectorstores.Option) error
DeleteDocuments removes documents from the vector store by their IDs.
func (*Store) GetBatchConfig ¶ added in v0.2.0
func (s *Store) GetBatchConfig() BatchConfig
GetBatchConfig returns the current batch configuration
func (*Store) GetBatchStats ¶ added in v0.2.0
func (s *Store) GetBatchStats(ctx context.Context, collectionName string) (map[string]interface{}, error)
GetBatchStats returns statistics about batch operations
func (*Store) ListCollections ¶
ListCollections returns all collection names in the Qdrant instance.
func (*Store) SetBatchConfig ¶ added in v0.2.0
func (s *Store) SetBatchConfig(config BatchConfig)
SetBatchConfig updates the batch configuration
func (*Store) SimilaritySearch ¶
func (s *Store) SimilaritySearch( ctx context.Context, query string, numDocuments int, options ...vectorstores.Option, ) ([]schema.Document, error)
SimilaritySearch performs vector similarity search with comprehensive logging.
func (*Store) SimilaritySearchWithScores ¶
func (s *Store) SimilaritySearchWithScores( ctx context.Context, query string, numDocuments int, options ...vectorstores.Option, ) ([]vectorstores.DocumentWithScore, error)
SimilaritySearchWithScores performs similarity search returning documents with similarity scores.