How to Set Up a Vector Database with Qdrant
Qdrant is an open-source vector similarity search engine designed for storing and querying high-dimensional embedding vectors. It is essential for building semantic search, recommendation systems, and retrieval-augmented generation (RAG) pipelines on your Breeze.
Prerequisites
- A Breeze instance with at least 2 GB of RAM
- Docker installed (recommended) or Rust toolchain for building from source
- Basic familiarity with REST APIs
Installing Qdrant with Docker
The simplest way to get Qdrant running on your Breeze is with Docker:
docker pull qdrant/qdrant
docker run -d --name qdrant \
-p 6333:6333 -p 6334:6334 \
-v /data/qdrant:/qdrant/storage \
qdrant/qdrant
Port 6333 serves the REST API and port 6334 serves the gRPC API. The data is persisted to /data/qdrant on your Breeze.
Installing Without Docker
If you prefer running natively, download the pre-built binary:
wget https://github.com/qdrant/qdrant/releases/latest/download/qdrant-x86_64-unknown-linux-musl.tar.gz
tar xzf qdrant-x86_64-unknown-linux-musl.tar.gz
./qdrant
Creating a Collection
Collections in Qdrant store vectors with associated metadata (payloads). Create one using the REST API:
curl -X PUT http://localhost:6333/collections/documents \
-H "Content-Type: application/json" \
-d '{
"vectors": {
"size": 384,
"distance": "Cosine"
}
}'
The vector size should match your embedding model’s output dimension. For example, all-MiniLM-L6-v2 produces 384-dimensional vectors.
Inserting Vectors
Upsert points (vectors with payloads) into your collection:
curl -X PUT http://localhost:6333/collections/documents/points \
-H "Content-Type: application/json" \
-d '{
"points": [
{"id": 1, "vector": [0.1, 0.2, ...], "payload": {"title": "Getting Started", "category": "tutorial"}},
{"id": 2, "vector": [0.3, 0.4, ...], "payload": {"title": "Advanced Usage", "category": "guide"}}
]
}'
Searching for Similar Vectors
Query the collection to find the most similar vectors:
curl -X POST http://localhost:6333/collections/documents/points/search \
-H "Content-Type: application/json" \
-d '{
"vector": [0.1, 0.2, ...],
"limit": 5,
"with_payload": true
}'
Qdrant returns the top matches ranked by similarity score, along with their payloads.
Using the Python Client
For programmatic access from your application, install the Python client:
pip install qdrant-client sentence-transformers
from qdrant_client import QdrantClient
from sentence_transformers import SentenceTransformer
client = QdrantClient(host="localhost", port=6333)
encoder = SentenceTransformer("all-MiniLM-L6-v2")
query_vector = encoder.encode("How do I deploy my application?").tolist()
results = client.search(collection_name="documents", query_vector=query_vector, limit=5)
for r in results:
print(r.payload["title"], r.score)
Enabling API Key Authentication
Protect your Qdrant instance by setting an API key in the configuration file or via environment variable:
docker run -d --name qdrant \
-p 6333:6333 \
-e QDRANT__SERVICE__API_KEY=your-secret-key \
qdrant/qdrant
With this configuration, all requests to your Qdrant instance on your Breeze must include the api-key header.