Documentation
¶
Overview ¶
Package qdrantkit provides an HTTP client for Qdrant vector database. Built on chassis call.Client for retry, circuit breaker, and OTel tracing.
Replaces custom Qdrant REST clients in equinox_graph, equinox_api, airborne, bizops, and agent-memory-benchmark.
Index ¶
- type Client
- func (c *Client) Check() health.Check
- func (c *Client) CreateCollection(ctx context.Context, name string, cfg CollectionConfig) error
- func (c *Client) CreatePayloadIndex(ctx context.Context, collection, field, fieldType string) error
- func (c *Client) Delete(ctx context.Context, collection string, ids []string) error
- func (c *Client) DeleteCollection(ctx context.Context, name string) error
- func (c *Client) GetCollection(ctx context.Context, name string) (*CollectionInfo, error)
- func (c *Client) GetVectors(ctx context.Context, collection string, ids []string) (map[string][]float32, error)
- func (c *Client) ListCollections(ctx context.Context) ([]string, error)
- func (c *Client) Ping(ctx context.Context) error
- func (c *Client) Scroll(ctx context.Context, collection string, opts ScrollOptions) (*ScrollResult, error)
- func (c *Client) Search(ctx context.Context, collection string, vector []float32, opts SearchOptions) ([]ScoredPoint, error)
- func (c *Client) Upsert(ctx context.Context, collection string, points []Point) error
- type CollectionConfig
- type CollectionInfo
- type Condition
- type Config
- type Distance
- type Filter
- type Option
- type Point
- type RangeOpt
- type ScoredPoint
- type ScrollOptions
- type ScrollResult
- type SearchOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is an HTTP client for Qdrant backed by call.Client.
func (*Client) CreateCollection ¶
CreateCollection creates a collection with the given vector configuration. Returns nil if the collection already exists (HTTP 409).
func (*Client) CreatePayloadIndex ¶
CreatePayloadIndex creates a field index for filtered search performance. Returns nil if the index already exists.
func (*Client) DeleteCollection ¶
DeleteCollection deletes a collection. Returns nil if not found (HTTP 404).
func (*Client) GetCollection ¶
GetCollection returns info about a collection. Returns nil, nil if not found.
func (*Client) GetVectors ¶
func (c *Client) GetVectors(ctx context.Context, collection string, ids []string) (map[string][]float32, error)
GetVectors fetches vectors by point IDs. Returns a map from ID to vector.
func (*Client) ListCollections ¶
ListCollections returns the names of all collections.
func (*Client) Scroll ¶
func (c *Client) Scroll(ctx context.Context, collection string, opts ScrollOptions) (*ScrollResult, error)
Scroll performs a paginated scan of points in a collection.
func (*Client) Search ¶
func (c *Client) Search(ctx context.Context, collection string, vector []float32, opts SearchOptions) ([]ScoredPoint, error)
Search performs a nearest-neighbor vector search.
type CollectionConfig ¶
CollectionConfig defines parameters for creating a collection.
type CollectionInfo ¶
type CollectionInfo struct {
Status string `json:"status"`
VectorsCount int64 `json:"vectors_count"`
PointsCount int64 `json:"points_count"`
}
CollectionInfo contains details about a collection.
type Condition ¶
type Condition struct {
// contains filtered or unexported fields
}
Condition is a single filter predicate. Build with Match, Range, or HasID.
func (Condition) MarshalJSON ¶
MarshalJSON produces the Qdrant JSON representation of the condition.
type Config ¶
type Config struct {
BaseURL string `env:"QDRANT_URL" default:"http://localhost:6333"`
APIKey string `env:"QDRANT_API_KEY" required:"false"`
Timeout time.Duration `env:"QDRANT_TIMEOUT" default:"10s"`
}
Config holds Qdrant connection settings.
type Filter ¶
type Filter struct {
Must []Condition `json:"must,omitempty"`
Should []Condition `json:"should,omitempty"`
MustNot []Condition `json:"must_not,omitempty"`
}
Filter is a Qdrant filter with boolean clauses. Use Must, Should, or MustNot constructors, or build the struct directly for complex filters.
type Option ¶
type Option func(*options)
Option configures a Client.
func WithCircuitBreaker ¶
WithCircuitBreaker protects the client with a named circuit breaker.
func WithHTTPClient ¶
WithHTTPClient replaces the underlying *http.Client used by call.Client.
func WithRetry ¶
WithRetry enables automatic retries for transient (5xx) errors using exponential backoff with jitter.
func WithTimeout ¶
WithTimeout overrides the default per-request timeout.
type Point ¶
type Point struct {
ID string `json:"id"`
Vector []float32 `json:"vector"`
Payload map[string]any `json:"payload,omitempty"`
}
Point is a vector with ID and optional payload, used for upsert.
type ScoredPoint ¶
type ScoredPoint struct {
ID string `json:"id"`
Score float32 `json:"score"`
Payload map[string]any `json:"payload,omitempty"`
Vector []float32 `json:"vector,omitempty"`
}
ScoredPoint is a search result with similarity score.
type ScrollOptions ¶
type ScrollOptions struct {
Limit int
Filter *Filter
Offset *string
WithPayload bool
WithVector bool
}
ScrollOptions configures a scroll (paginated scan) query.
type ScrollResult ¶
type ScrollResult struct {
Points []ScoredPoint
NextPageOffset *string
}
ScrollResult is a page from a scroll query.