核心功能
Qdrant 是 Rust 编写的开源向量数据库与搜索引擎,把向量近邻检索和 payload 结构化过滤放在同一次查询里完成。适合需要在语义召回之上再按标签、价格等字段筛选的搜索与推荐团队。它的 Python 客户端提供本地模式,不启服务端也能跑同样的代码,原型与 CI 接入成本很低。
功能亮点
本地模式免服务端
QdrantClient(":memory:") 或指定磁盘路径即可运行,不用先起容器
自带 Web 面板
启动后打开 localhost:6333/dashboard 查看集合与数据点
检索时直接过滤
Filter 搭配 FieldCondition 与 Range,检索过程中按字段筛选
客户端内置向量化
装 qdrant-client[fastembed] 后可直接传原始文本入库
适用场景
• 语义搜索叠加条件筛选,比如按类目和价格区间过滤后再做向量召回
• 推荐系统的候选召回层,用 payload 条件排除用户已浏览过的内容
• 在 CI 流水线里用 local mode 跑向量检索相关单测,不依赖外部服务
安装配置
bash
Docker:
docker pull qdrant/qdrant
docker run -p 6333:6333 -p 6334:6334 \
-v "$(pwd)/qdrant_storage:/qdrant/storage:z" \
qdrant/qdrant
Python 客户端:
pip install qdrant-client
需要客户端本地做文本向量化时(CPU):
pip install qdrant-client[fastembed]
说明:REST API 在 localhost:6333,Web UI 在 localhost:6333/dashboard,gRPC API 在 localhost:6334。fastembed 与 fastembed-gpu 互斥,只能装其中一个。使用方法
python
连接服务端:
from qdrant_client import QdrantClient
client = QdrantClient(url="http://localhost:6333")
本地模式(不启服务端,代码完全一致):
client = QdrantClient(":memory:")
# 或持久化到磁盘
client = QdrantClient(path="path/to/db")
创建集合:
from qdrant_client.models import Distance, VectorParams
client.create_collection(
collection_name="test_collection",
vectors_config=VectorParams(size=4, distance=Distance.DOT),
)
写入向量与 payload:
from qdrant_client.models import PointStruct
operation_info = client.upsert(
collection_name="test_collection",
wait=True,
points=[
PointStruct(id=1, vector=[0.05, 0.61, 0.76, 0.74], payload={"city": "Berlin"}),
PointStruct(id=2, vector=[0.19, 0.81, 0.75, 0.11], payload={"city": "London"}),
PointStruct(id=3, vector=[0.36, 0.55, 0.47, 0.94], payload={"city": "Moscow"}),
],
)
检索:
search_result = client.query_points(
collection_name="test_collection",
query=[0.2, 0.1, 0.9, 0.7],
with_payload=False,
limit=3
).points
带条件过滤的检索:
from qdrant_client.models import Filter, FieldCondition, Range
hits = client.query_points(
collection_name="my_collection",
query=query_vector,
query_filter=Filter(
must=[
FieldCondition(
key='rand_number',
range=Range(gte=3)
)
]
),
limit=5
)关键指标
尚未核验对标产品,此处只列本工具自身指标,不做对比结论。
指标Qdrant
价格免费增值
开源是
上手难度入门
相关工具
优点
- Rust 实现、Apache 2.0 开源,同时开放 REST(6333)与 gRPC(6334)接口,gRPC 模式官方标注上传通常更快
- Python 客户端的 local mode 让原型、CI 测试与生产共用同一套 API,扩容时只需换成服务端连接
- 支持在检索过程中用 Filter / FieldCondition / Range 做 payload 条件过滤,而非查询后再筛
- 集群侧用 Raft 维护拓扑一致性,并提供 stream_records、snapshot、wal_delta 多种分片传输方式
缺点
- 集合的 shard_number 创建后不能修改,官方明确在线 resharding 只在 Qdrant Cloud 可用,自托管需重建集合
- 自托管开源版创建集合后修改 replication_factor 不会生效,需手动调用 replicate_shard / drop_replica
- 官方说明 Qdrant 客户端不会自行在多个节点间分发请求,分布式部署需自建负载均衡
- 使用自定义分片时 ID 只在单个 shard key 内保证唯一,官方称这是当前实现的限制且属于应避免的反模式