Qdrant
Port 6333 Vector similarity search for semantic search and RAG.
Qdrant does not embed text. Your API generates embeddings and stores vectors here.
Connection
QDRANT_URL=http://db.bizfylabs.com:6333
QDRANT_API_KEY=YOUR_API_KEY
Setup (Python)
pip install qdrant-client
from qdrant_client import QdrantClient
from qdrant_client.models import Distance, VectorParams, PointStruct, Filter, FieldCondition, MatchValue
client = QdrantClient(url=os.environ["QDRANT_URL"], api_key=os.environ["QDRANT_API_KEY"])
Collection CRUD
Name collections per app: myapp_documents, myapp_products
Create Collection
# Vector size must match embedding model (OpenAI text-embedding-3-small = 1536)
client.create_collection(
collection_name="myapp_documents",
vectors_config=VectorParams(size=1536, distance=Distance.COSINE),
)
Read — List / Get Info
client.get_collections()
client.get_collection("myapp_documents")
Update Collection
from qdrant_client.models import OptimizersConfigDiff
client.update_collection(
collection_name="myapp_documents",
optimizers_config=OptimizersConfigDiff(indexing_threshold=20000),
)
Delete Collection
client.delete_collection("myapp_documents") # destructive
Point (Vector) CRUD
Create / Upsert Points
client.upsert(
collection_name="myapp_documents",
points=[
PointStruct(
id="doc-001",
vector=embedding, # list[float] from your model
payload={"title": "Getting Started", "source": "wiki", "text": "..."},
),
PointStruct(id="doc-002", vector=embedding2, payload={"title": "API Ref"}),
],
)
Read — Search & Retrieve
# Similarity search
results = client.search(
collection_name="myapp_documents",
query_vector=query_embedding,
limit=5,
score_threshold=0.7,
)
# Get by ID
client.retrieve(collection_name="myapp_documents", ids=["doc-001"])
# Scroll all (paginated)
client.scroll(collection_name="myapp_documents", limit=100)
Read — With Metadata Filter
results = client.search(
collection_name="myapp_documents",
query_vector=query_embedding,
query_filter=Filter(must=[
FieldCondition(key="source", match=MatchValue(value="wiki"))
]),
limit=10,
)
Update Payload (metadata)
client.set_payload(
collection_name="myapp_documents",
payload={"title": "Updated Title", "status": "published"},
points=["doc-001"],
)
# Overwrite entire payload
client.overwrite_payload(
collection_name="myapp_documents",
payload={"title": "New"},
points=["doc-001"],
)
Delete Points
client.delete(
collection_name="myapp_documents",
points_selector=["doc-001", "doc-002"],
)
# Delete by filter
from qdrant_client.models import FilterSelector, FieldCondition, MatchValue
client.delete(
collection_name="myapp_documents",
points_selector=FilterSelector(filter=Filter(must=[
FieldCondition(key="source", match=MatchValue(value="draft"))
])),
)
Node.js CRUD
import { QdrantClient } from '@qdrant/js-client-rest';
const client = new QdrantClient({ url: process.env.QDRANT_URL, apiKey: process.env.QDRANT_API_KEY });
await client.createCollection('myapp_documents', {
vectors: { size: 1536, distance: 'Cosine' },
});
await client.upsert('myapp_documents', {
points: [{ id: 'doc-001', vector: embedding, payload: { title: 'Hello' } }],
});
const results = await client.search('myapp_documents', {
vector: queryEmbedding, limit: 5,
});
await client.delete('myapp_documents', { points: ['doc-001'] });
RAG Pipeline
def rag_query(question: str) -> str:
query_vector = embed(question)
hits = client.search(collection_name="myapp_documents", query_vector=query_vector, limit=5)
context = "\n".join(hit.payload["text"] for hit in hits)
return llm.generate(f"Context:\n{context}\n\nQ: {question}")
Admin — Collections & API Key
Qdrant uses one shared API key. Per-app isolation is by collection naming.
# List collections
curl -s -H "api-key: $KEY" http://db.bizfylabs.com:6333/collections
# Collection info
curl -s -H "api-key: $KEY" http://db.bizfylabs.com:6333/collections/myapp_documents
# Delete collection
curl -X DELETE -H "api-key: $KEY" http://db.bizfylabs.com:6333/collections/myapp_documents
# Rotate API key: update QDRANT_API_KEY in /srv/databases/.env, then:
cd /srv/databases && docker compose restart qdrant
Send to Developer
QDRANT_URL=http://db.bizfylabs.com:6333
QDRANT_API_KEY=YOUR_KEY
# Use collection prefix: myapp_documents