Skip to content
Docs

Qdrant Vector Store Provider

The Qdrant provider implements the vectorstore.VectorStore interface using Qdrant’s HTTP REST API. It avoids gRPC dependencies for broad compatibility while supporting cosine, dot-product, and Euclidean distance strategies.

Choose Qdrant when you need a purpose-built vector database with strong performance characteristics and flexible deployment options. Qdrant can run self-hosted via Docker for development or in production on Qdrant Cloud. It supports payload-based filtering, rich data types, and HNSW indexing for fast approximate nearest-neighbor search.

Terminal window
go get github.com/lookatitude/beluga-ai/rag/vectorstore/providers/qdrant

Start Qdrant locally:

Terminal window
docker run -p 6333:6333 qdrant/qdrant
package main
import (
"context"
"log"
"github.com/lookatitude/beluga-ai/config"
"github.com/lookatitude/beluga-ai/rag/vectorstore"
"github.com/lookatitude/beluga-ai/schema"
_ "github.com/lookatitude/beluga-ai/rag/vectorstore/providers/qdrant"
)
func main() {
store, err := vectorstore.New("qdrant", config.ProviderConfig{
BaseURL: "http://localhost:6333",
Options: map[string]any{
"collection": "my_documents",
"dimension": float64(1536),
},
})
if err != nil {
log.Fatal(err)
}
ctx := context.Background()
docs := []schema.Document{
{ID: "doc1", Content: "Go is a statically typed language", Metadata: map[string]any{"lang": "en"}},
}
embeddings := [][]float32{make([]float32, 1536)}
err = store.Add(ctx, docs, embeddings)
if err != nil {
log.Fatal(err)
}
}
ParameterTypeDefaultDescription
BaseURLstring(required)Qdrant server URL
APIKeystring(optional)API key for authentication
Options["collection"]stringdocumentsCollection name
Options["dimension"]float641536Vector dimensionality

Use EnsureCollection to create the collection with cosine distance:

import (
qdrantstore "github.com/lookatitude/beluga-ai/rag/vectorstore/providers/qdrant"
)
store, err := qdrantstore.NewFromConfig(config.ProviderConfig{
BaseURL: "http://localhost:6333",
Options: map[string]any{
"collection": "my_documents",
"dimension": float64(768),
},
})
if err != nil {
log.Fatal(err)
}
err = store.EnsureCollection(ctx)
if err != nil {
log.Fatal(err)
}
store := qdrantstore.New("http://localhost:6333",
qdrantstore.WithCollection("my_documents"),
qdrantstore.WithDimension(768),
qdrantstore.WithAPIKey(os.Getenv("QDRANT_API_KEY")),
)

Qdrant supports payload-based filtering using its must filter clause:

results, err := store.Search(ctx, queryVec, 10,
vectorstore.WithFilter(map[string]any{
"lang": "en",
"category": "technical",
}),
)

Set a minimum similarity score to exclude low-relevance results at the Qdrant API level:

results, err := store.Search(ctx, queryVec, 10,
vectorstore.WithThreshold(0.7),
)

Connect to Qdrant Cloud by providing the cluster URL and API key:

store, err := vectorstore.New("qdrant", config.ProviderConfig{
BaseURL: "https://abc123.us-east4-0.gcp.cloud.qdrant.io:6333",
APIKey: os.Getenv("QDRANT_API_KEY"),
Options: map[string]any{
"collection": "production",
},
})
store := qdrantstore.New("http://localhost:6333",
qdrantstore.WithHTTPClient(customClient),
qdrantstore.WithCollection("my_documents"),
)