qdrant-vector-db
Skill0 starsChanged 4 months agoMITView on GitHub
Qdrant vector database best practices for semantic search, RAG, collections, filtering, and performance. Use when working with Qdrant collections, vector search, embeddings, payload filtering, or optimizing vector database queries. Essential for news search and context retrieval.
In this repository11 other files it gives its agents.
- advanced-sql-timescaleSkill
- backtesting-disciplineSkill
- crypto-liquidity-flowSkill
- fastapi-best-practicesSkill
- llm-integrationSkill
- market-microstructureSkill
- redis-patternsSkill
- risk-managementSkill
- senior-prompt-engineerSkill
- strategy-optimizationSkill
- websocket-realtimeSkill
The file
We split this skill into the rules it gives an agent
3 rules. About 0 are common, 2 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 235
Wait for indexing after large uploads before searching
- Very specific: line 236
Use client.update_collection() to change optimizer settings
- Distinctive: line 241
Use consistent embedding model across insert and search
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Qdrant Vector Database Best Practices
Production patterns for Qdrant vector search. Covers collections, search, filtering, and performance optimization.
When to Apply
- Creating or modifying Qdrant collections
- Implementing semantic search for news/documents
- Building RAG pipelines with vector retrieval
- Optimizing search performance and accuracy
- Managing payload indexes and filtering
1. Collection Configuration (CRITICAL)
Create optimized collection
from qdrant_client import QdrantClient
from qdrant_client.models import (
Distance, VectorParams, OptimizersConfigDiff,
ScalarQuantization, ScalarQuantizationConfig, ScalarType,
HnswConfigDiff, PayloadSchemaType
)
client = QdrantClient(host="localhost", port=6333)
# High-speed with low memory
client.create_collection(
collection_name="telegram_news_v2",
vectors_config=VectorParams(
size=384, # Match your embedding model
distance=Distance.COSINE,
on_disk=True # Keep vectors on disk
),
quantization_config=ScalarQuantization(
scalar=ScalarQuantizationConfig(
type=ScalarType.INT8,
always_ram=True # Quantized in RAM for speed
)
),
hnsw_config=HnswConfigDiff(
m=16, # Number of links per node
ef_construct=100, # Build-time precision
on_disk=False # HNSW graph in RAM
),
optimizers_config=OptimizersConfigDiff(
memmap_threshold=20000
)
)HNSW tuning guide
| Param | Low (fast, less accurate) | Default | High (slow, more accurate) |
m | 8 | 16 | 32 |
ef_construct | 50 | 100 | 200 |
Distance metrics
COSINE- Best for normalized embeddings (most common)DOT- For non-normalized, when magnitude mattersEUCLID- For spatial/geographic data
2. Payload Indexing (CRITICAL)
ALWAYS create indexes BEFORE uploading data
# Index text fields for exact match filtering
client.create_payload_index(
collection_name="telegram_news_v2",
field_name="source",
field_schema=PayloadSchemaType.KEYWORD
)
# Index datetime fields for range queries
client.create_payload_index(
collection_name="telegram_news_v2",
field_name="timestamp",
field_schema=PayloadSchemaType.DATETIME
)
# Index numeric fields for range filtering
client.create_payload_index(
collection_name="telegram_news_v2",
field_name="relevance_score",
field_schema=PayloadSchemaType.FLOAT
)Why: Without indexes, Qdrant does full scan on payloads = SLOW
3. Search Patterns (HIGH)
Basic semantic search
from qdrant_client.models import Filter, FieldCondition, MatchValue, Range
results = client.search(
collection_name="telegram_news_v2",
query_vector=embedding,
limit=10,
score_threshold=0.7, # Minimum similarity
with_payload=True
)Filtered search (combine semantic + metadata)
from datetime import datetime, timedelta
results = client.search(
collection_name="telegram_news_v2",
query_vector=embedding,
query_filter=Filter(
must=[
FieldCondition(
key="timestamp",
range=Range(
gte=(datetime.utcnow() - timedelta(hours=24)).isoformat()
)
),
FieldCondition(
key="source",
match=MatchValue(value="crypto_news")
)
]
),
limit=5,
with_payload=["title", "text", "timestamp", "source"]
)Search with payload selection (reduce transfer)
# Only return specific fields
results = client.search(
collection_name="telegram_news_v2",
query_vector=embedding,
limit=10,
with_payload=["title", "summary", "timestamp"] # Not full text
)4. Upsert Patterns (HIGH)
Batch upsert
from qdrant_client.models import PointStruct
points = [
PointStruct(
id=hash(article["url"]) & 0xFFFFFFFF, # Deterministic ID
vector=embedding,
payload={
"title": article["title"],
"text": article["text"],
"source": article["source"],
"timestamp": article["timestamp"].isoformat(),
"symbols": article.get("symbols", []),
}
)
for article, embedding in zip(articles, embeddings)
]
# Batch upload (max ~100 per batch)
client.upsert(
collection_name="telegram_news_v2",
points=points
)Idempotent upsert (use deterministic IDs)
- Hash URL or unique identifier for point ID
- Re-upserting same ID overwrites cleanly
- Prevents duplicates
5. Advanced Filtering
Complex filters
# Must match ANY of these sources AND be recent
filter = Filter(
must=[
FieldCondition(
key="timestamp",
range=Range(gte="2026-02-07T00:00:00Z")
)
],
should=[ # OR logic
FieldCondition(key="source", match=MatchValue(value="bloomberg")),
FieldCondition(key="source", match=MatchValue(value="reuters")),
FieldCondition(key="source", match=MatchValue(value="coindesk"))
]
)Nested object filtering
# Filter by nested payload field
FieldCondition(
key="metadata.language",
match=MatchValue(value="en")
)6. Performance Optimization
Query tuning
# Override HNSW ef at query time (higher = more accurate, slower)
results = client.search(
collection_name="telegram_news_v2",
query_vector=embedding,
limit=10,
search_params=SearchParams(
hnsw_ef=128, # Default usually 100
exact=False # Set True for small collections (<1000)
)
)Collection stats
info = client.get_collection("telegram_news_v2")
print(f"Points: {info.points_count}")
print(f"Indexed: {info.indexed_vectors_count}")
print(f"Status: {info.status}")Maintenance
- Monitor
indexed_vectors_countvspoints_count - Wait for indexing after large uploads before searching
- Use
client.update_collection()to change optimizer settings - Compact collection after many deletes
7. Embedding Best Practices
- Use consistent embedding model across insert and search
- Normalize embeddings for cosine similarity
- Cache embeddings for frequently searched queries
- Batch embedding generation for efficiency
- Model size: 384 dims (fast) vs 768/1024 dims (more accurate)
8. Error Handling
from qdrant_client.http.exceptions import UnexpectedResponse
try:
results = client.search(...)
except UnexpectedResponse as e:
logger.error(f"Qdrant error: {e.status_code} - {e.content}")
# Fallback to cached results
except ConnectionError:
logger.error("Qdrant connection lost")
# Retry with backoffDoes it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

