Documentation
¶
Overview ¶
Package qdrant provides a Qdrant vector database integration for GoFrame.
Qdrant is a high-performance vector database optimized for similarity search. Implements the vectorstores.VectorStore interface for document storage, retrieval, and hybrid search with both dense and sparse vectors.
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 WithBinaryQuantization(enabled bool) Option
- func WithCollectionName(name string) Option
- func WithContentKey(contentKey string) Option
- func WithEmbedder(embedder embeddings.Embedder) Option
- func WithGrpcOptions(opts ...grpc.DialOption) Option
- func WithHost(host string) Option
- func WithHostAndPort(host string, port int) Option
- func WithKeepaliveTime(d time.Duration) Option
- func WithKeepaliveTimeout(d time.Duration) Option
- func WithLogger(logger *slog.Logger) Option
- func WithMaxRetryDelay(delay time.Duration) Option
- func WithPayloadIndex(keys ...string) Option
- func WithPoolSize(size int) Option
- func WithRetryAttempts(attempts int) Option
- func WithRetryDelay(delay time.Duration) Option
- func WithRetryJitter(jitter time.Duration) Option
- func WithSparseVector(name string) Option
- func WithTLS(useTLS bool) Option
- func WithTimeout(timeout time.Duration) 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) Close() 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) DeleteDocumentsByFilter(ctx context.Context, filters map[string]any, options ...vectorstores.Option) error
- func (s *Store) GetBatchConfig() BatchConfig
- func (s *Store) GetEmbedder() embeddings.Embedder
- 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) SimilaritySearchBatch(ctx context.Context, queries []string, numDocuments int, ...) ([][]schema.Document, error)
- func (s *Store) SimilaritySearchWithScores(ctx context.Context, query string, numDocuments int, ...) ([]vectorstores.DocumentWithScore, error)
Constants ¶
const ( DefaultBatchSize = 100 MaxBatchSize = 1000 DefaultMaxConcurrency = 8 DefaultRetryAttempts = 3 DefaultRetryDelay = 2 * time.Second DefaultMaxRetryDelay = 30 * time.Second DefaultRetryJitter = 1 * time.Second // DefaultDenseVectorName is the implicit name for the default dense vector in Qdrant. DefaultDenseVectorName = "" )
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") ErrEmbeddingTotalFailure = errors.New("qdrant: all embedding batches failed") ErrMissingSparseName = errors.New("qdrant: sparse vector name required for hybrid search configuration") )
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"`
EmbeddingBatchSize int `json:"embedding_batch_size,omitempty"`
RetryJitter time.Duration `json:"retry_jitter"`
EmbeddingMaxConcurrency int `json:"embedding_max_concurrency,omitempty"`
}
type BatchResult ¶ added in v0.2.0
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 WithBinaryQuantization ¶ added in v0.15.0
WithBinaryQuantization enables binary quantization for the collection.
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 WithGrpcOptions ¶ added in v0.15.0
func WithGrpcOptions(opts ...grpc.DialOption) Option
WithGrpcOptions sets custom gRPC dial options for advanced configuration. These are appended to the default dial options.
func WithHostAndPort ¶
WithHostAndPort sets the Qdrant server host and port.
func WithKeepaliveTime ¶ added in v0.15.0
WithKeepaliveTime sets the interval between keepalive pings. This helps maintain connection health in long-running scenarios.
func WithKeepaliveTimeout ¶ added in v0.15.0
WithKeepaliveTimeout sets the timeout for keepalive ping responses.
func WithLogger ¶
WithLogger sets the logger for the Qdrant store.
func WithMaxRetryDelay ¶ added in v0.15.0
WithMaxRetryDelay sets the maximum delay between retry attempts.
func WithPayloadIndex ¶ added in v0.15.0
WithPayloadIndex specifies keys to be indexed in the payload.
func WithPoolSize ¶ added in v0.15.0
WithPoolSize sets the gRPC connection pool size. A larger pool can handle more concurrent requests.
func WithRetryAttempts ¶
WithRetryAttempts sets the number of retry attempts for failed operations.
func WithRetryDelay ¶ added in v0.15.0
WithRetryDelay sets the initial delay between retry attempts.
func WithRetryJitter ¶ added in v0.15.0
WithRetryJitter sets the random jitter added to retry delays.
func WithSparseVector ¶ added in v0.15.0
WithSparseVector adds a named sparse vector configuration.
func WithTimeout ¶
WithTimeout sets the connection timeout.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
func (*Store) AddDocuments ¶
func (*Store) AddDocumentsBatch ¶ added in v0.2.0
func (*Store) Close ¶ added in v0.15.0
Close closes the gRPC connection to the Qdrant server. It should be called when the Store is no longer needed to release resources.
func (*Store) CreateCollection ¶
func (*Store) DeleteCollection ¶
func (*Store) DeleteDocuments ¶
func (*Store) DeleteDocumentsByFilter ¶ added in v0.6.0
func (*Store) GetBatchConfig ¶ added in v0.2.0
func (s *Store) GetBatchConfig() BatchConfig
func (*Store) GetEmbedder ¶ added in v0.15.0
func (s *Store) GetEmbedder() embeddings.Embedder
GetEmbedder returns the embedder used by the store.
func (*Store) ListCollections ¶
func (*Store) SetBatchConfig ¶ added in v0.2.0
func (s *Store) SetBatchConfig(config BatchConfig)
func (*Store) SimilaritySearch ¶
func (*Store) SimilaritySearchBatch ¶ added in v0.7.0
func (*Store) SimilaritySearchWithScores ¶
func (s *Store) SimilaritySearchWithScores( ctx context.Context, query string, numDocuments int, options ...vectorstores.Option, ) ([]vectorstores.DocumentWithScore, error)