qdrant

package
v0.9.21 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2026 License: MIT Imports: 14 Imported by: 2 modules, 2 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildFilter

func BuildFilter(conditions map[string]interface{}) (*qdrant.Filter, error)

BuildFilter is a helper to construct Qdrant filters from key-value pairs

Types

type Adapter

type Adapter struct {
	*Client
	// contains filtered or unexported fields
}

Adapter wraps the Qdrant client to implement the vectordb.VectorDBClient interface

func NewAdapter

func NewAdapter(config *vectordb.Config) (*Adapter, error)

NewAdapter creates a new Qdrant adapter from the vectordb.Config

func (*Adapter) CreateCollection

func (a *Adapter) CreateCollection(ctx context.Context, name string, schema *vectordb.CollectionSchema) error

CreateCollection creates a new collection with the given schema

func (*Adapter) CreateDocument

func (a *Adapter) CreateDocument(ctx context.Context, collectionName string, document *vectordb.Document) error

CreateDocument creates a new document in the specified collection

func (*Adapter) CreateDocuments

func (a *Adapter) CreateDocuments(ctx context.Context, collectionName string, documents []*vectordb.Document) error

CreateDocuments creates multiple documents in batch

func (*Adapter) DeleteDocumentsByMetadata

func (a *Adapter) DeleteDocumentsByMetadata(ctx context.Context, collectionName string, metadata map[string]interface{}) error

DeleteDocumentsByMetadata deletes documents matching metadata criteria

func (*Adapter) GetDefaultSchema

func (a *Adapter) GetDefaultSchema(schemaType vectordb.SchemaType, collectionName string) *vectordb.CollectionSchema

GetDefaultSchema returns a default schema for the given type

func (*Adapter) GetDocument

func (a *Adapter) GetDocument(ctx context.Context, collectionName, documentID string) (*vectordb.Document, error)

GetDocument retrieves a document by ID

func (*Adapter) GetSchema

func (a *Adapter) GetSchema(ctx context.Context, collectionName string) (*vectordb.CollectionSchema, error)

GetSchema retrieves the schema for a collection

func (*Adapter) ListCollections

func (a *Adapter) ListCollections(ctx context.Context) ([]vectordb.CollectionInfo, error)

ListCollections returns a list of all collections

func (*Adapter) ListDocuments

func (a *Adapter) ListDocuments(ctx context.Context, collectionName string, limit int, offset int) ([]*vectordb.Document, error)

ListDocuments returns a list of documents in a collection

func (*Adapter) SearchBM25

func (a *Adapter) SearchBM25(ctx context.Context, collectionName, query string, options *vectordb.QueryOptions) ([]*vectordb.QueryResult, error)

SearchBM25 performs keyword-based search using BM25

func (*Adapter) SearchByMetadata

func (a *Adapter) SearchByMetadata(ctx context.Context, collectionName string, metadata map[string]interface{}, options *vectordb.QueryOptions) ([]*vectordb.QueryResult, error)

SearchByMetadata searches documents by metadata fields

func (*Adapter) SearchHybrid

func (a *Adapter) SearchHybrid(ctx context.Context, collectionName, query string, options *vectordb.QueryOptions) ([]*vectordb.QueryResult, error)

SearchHybrid performs hybrid search combining vector and keyword search

func (*Adapter) SearchSemantic

func (a *Adapter) SearchSemantic(ctx context.Context, collectionName, query string, options *vectordb.QueryOptions) ([]*vectordb.QueryResult, error)

SearchSemantic performs semantic search using vector embeddings

func (*Adapter) UpdateDocument

func (a *Adapter) UpdateDocument(ctx context.Context, collectionName string, document *vectordb.Document) error

UpdateDocument updates an existing document

func (*Adapter) UpdateSchema

func (a *Adapter) UpdateSchema(ctx context.Context, collectionName string, schema *vectordb.CollectionSchema) error

UpdateSchema updates a collection's schema

func (*Adapter) ValidateSchema

func (a *Adapter) ValidateSchema(schema *vectordb.CollectionSchema) error

ValidateSchema validates a schema definition

type Client

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

Client wraps the Qdrant gRPC client with vector database functionality

func NewClient

func NewClient(config *Config) (*Client, error)

NewClient creates a new Qdrant client

func (*Client) Close

func (c *Client) Close() error

Close closes the Qdrant client connection

func (*Client) CollectionExists

func (c *Client) CollectionExists(ctx context.Context, name string) (bool, error)

CollectionExists checks if a collection exists

func (*Client) CreateCollection

func (c *Client) CreateCollection(ctx context.Context, name string, vectorDimensions int, similarityMetric string) error

CreateCollection creates a new collection in Qdrant with the specified vector configuration Also stores embedding model metadata for later retrieval

func (*Client) CreateDocument

func (c *Client) CreateDocument(ctx context.Context, collectionName string, doc *Document) error

CreateDocument inserts a single document (point) into a collection

func (*Client) CreateDocuments

func (c *Client) CreateDocuments(ctx context.Context, collectionName string, docs []*Document) error

CreateDocuments inserts multiple documents (points) into a collection in batch

func (*Client) DeleteAllDocuments added in v0.7.1

func (c *Client) DeleteAllDocuments(ctx context.Context, collectionName string) error

DeleteAllDocuments deletes all documents from a collection

func (*Client) DeleteCollection

func (c *Client) DeleteCollection(ctx context.Context, name string) error

DeleteCollection deletes a collection and all its data

func (*Client) DeleteDocument

func (c *Client) DeleteDocument(ctx context.Context, collectionName string, id string) error

DeleteDocument deletes a document by ID

func (*Client) DeleteDocuments

func (c *Client) DeleteDocuments(ctx context.Context, collectionName string, ids []string) error

DeleteDocuments deletes multiple documents by IDs

func (*Client) GetCollection

func (c *Client) GetCollection() string

GetCollection returns the current default collection name

func (*Client) GetCollectionCount

func (c *Client) GetCollectionCount(ctx context.Context, name string) (int64, error)

GetCollectionCount returns the number of points (documents) in a collection

func (*Client) GetCollectionInfo

func (c *Client) GetCollectionInfo(ctx context.Context, name string) (*qdrant.GetCollectionInfoResponse, error)

GetCollectionInfo retrieves information about a collection

func (*Client) GetDocument

func (c *Client) GetDocument(ctx context.Context, collectionName string, id string) (*Document, error)

GetDocument retrieves a document by ID

func (*Client) Health

func (c *Client) Health(ctx context.Context) error

Health checks if the Qdrant server is healthy and accessible

func (*Client) ListCollections

func (c *Client) ListCollections(ctx context.Context) ([]string, error)

ListCollections returns a list of all collection names

func (*Client) ListDocuments

func (c *Client) ListDocuments(ctx context.Context, collectionName string, limit int) ([]*Document, error)

ListDocuments retrieves all documents in a collection using scroll

func (*Client) SearchByMetadata

func (c *Client) SearchByMetadata(ctx context.Context, collectionName string, filter *qdrant.Filter, limit int) ([]*Document, error)

SearchByMetadata searches using metadata filters only

func (*Client) SearchHybrid

func (c *Client) SearchHybrid(ctx context.Context, collectionName string, vector []float32, filter *qdrant.Filter, topK int) ([]*SearchResult, error)

SearchHybrid performs a hybrid search combining vector similarity and metadata filtering

func (*Client) SearchSemantic

func (c *Client) SearchSemantic(ctx context.Context, collectionName string, vector []float32, topK int) ([]*SearchResult, error)

SearchSemantic performs a vector similarity search

func (*Client) SetCollection

func (c *Client) SetCollection(name string)

SetCollection sets the default collection name for operations

func (*Client) UpdateDocument

func (c *Client) UpdateDocument(ctx context.Context, collectionName string, doc *Document) error

UpdateDocument updates a document (same as create, uses upsert)

type Config

type Config struct {
	// Connection settings
	Host   string // Qdrant server host (e.g., "localhost")
	Port   int    // Qdrant server port (default: 6334 for gRPC)
	APIKey string // API key for Qdrant Cloud
	UseTLS bool   // Whether to use TLS (true for cloud, false for local)

	// Vector settings
	VectorDimensions int    // Embedding vector dimensions (e.g., 1536 for OpenAI)
	SimilarityMetric string // Distance metric: "Cosine", "Dot", or "Euclidean"

	// Connection settings
	Timeout int // Timeout in seconds for operations (default: 10)
}

Config holds Qdrant client configuration

type Document

type Document struct {
	ID       string                 // Unique document ID
	Vector   []float32              // Embedding vector
	Metadata map[string]interface{} // Payload metadata
	Content  string                 // Document content (stored in metadata)
}

Document represents a document with its vector and metadata (payload)

type Factory

type Factory struct{}

Factory implements the ClientFactory interface for Qdrant

func NewFactory

func NewFactory() *Factory

NewFactory creates a new Qdrant factory

func (*Factory) CreateClient

func (f *Factory) CreateClient(config *vectordb.Config) (vectordb.VectorDBClient, error)

CreateClient creates a new Qdrant client

func (*Factory) GetSupportedTypes

func (f *Factory) GetSupportedTypes() []vectordb.VectorDBType

GetSupportedTypes returns the list of supported database types

func (*Factory) ValidateConfig

func (f *Factory) ValidateConfig(config *vectordb.Config) error

ValidateConfig validates the configuration for Qdrant

type SearchResult

type SearchResult struct {
	Document *Document
	Score    float32
}

SearchResult represents a search result with a document and score

Jump to

Keyboard shortcuts

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