-
Notifications
You must be signed in to change notification settings - Fork 0
Qdrant
gitpavleenbali edited this page Feb 17, 2026
·
2 revisions
Qdrant is a high-performance, Rust-based vector database with rich filtering capabilities.
pip install pyai[vectordb]
# or specifically
pip install qdrant-clientdocker run -p 6333:6333 qdrant/qdrantSign up at cloud.qdrant.io
from pyai.vectordb import connect
# Local instance
db = connect("qdrant", url="http://localhost:6333")
# Qdrant Cloud
db = connect(
"qdrant",
url="https://your-cluster.qdrant.io",
api_key="your-api-key"
)
# With collection name
db = connect(
"qdrant",
url="http://localhost:6333",
collection_name="my_documents"
)from pyai.vectordb.qdrant import QdrantStore
store = QdrantStore(
url="http://localhost:6333",
collection_name="documents",
api_key=None, # Optional
embedding_model="text-embedding-3-small"
)# Simple add
db.add([
"First document",
"Second document"
])
# With metadata and IDs
db.add(
documents=["Document content"],
metadatas=[{"source": "web", "tags": ["python", "ai"]}],
ids=["doc-001"]
)results = db.search("query text", n=5)
for result in results:
print(f"ID: {result.id}")
print(f"Score: {result.score}")
print(f"Content: {result.content}")# Exact match
results = db.search(
"query",
n=10,
filter={
"must": [{"key": "source", "match": {"value": "web"}}]
}
)
# Range filter
results = db.search(
"query",
filter={
"must": [{"key": "year", "range": {"gte": 2023}}]
}
)db.update(
ids=["doc-001"],
documents=["Updated content"],
metadatas=[{"updated": True}]
)# By ID
db.delete(ids=["doc-001", "doc-002"])
# By filter
db.delete(filter={"must": [{"key": "archived", "match": {"value": True}}]})# Create collection
db.create_collection(
name="new_collection",
dimension=1536,
distance="cosine" # or "euclid", "dot"
)
# List collections
collections = db.list_collections()
# Delete collection
db.delete_collection("old_collection")Qdrant supports complex filtering:
filter = {
"must": [
{"key": "category", "match": {"value": "tech"}}
],
"should": [
{"key": "language", "match": {"value": "python"}},
{"key": "language", "match": {"value": "rust"}}
],
"must_not": [
{"key": "archived", "match": {"value": True}}
]
}
results = db.search("query", filter=filter)| Type | Description |
|---|---|
match |
Exact value match |
range |
Numeric range (gte, lte, gt, lt) |
geo_bounding_box |
Geographic bounds |
geo_radius |
Geographic radius |
# Enable scalar quantization for faster search
db = connect(
"qdrant",
url="...",
quantization="scalar"
)# Create collection with sharding
db.create_collection(
name="large_collection",
shard_number=3
)- VectorDB-Module - Module overview
- ChromaDB - Simple local option
- Pinecone - Managed cloud option
Intelligence, Embedded.