Weaviate 向量搜索引擎
Weaviate 是带 schema 的向量数据库,支持 BM25 与向量混合检索、模块化向量化和多租户。适合 RAG、语义搜索和知识库。
Docker 启动:
docker run -d --name weaviate \
-p 8080:8080 -p 50051:50051 \
-e AUTHENTICATION_ANONYMOUS_ACCESS_ENABLED=true \
-e PERSISTENCE_DATA_PATH=/var/lib/weaviate \
-v $(pwd)/weaviate:/var/lib/weaviate \
semitechnologies/weaviate:1.27.0
创建 schema:
curl -X POST http://localhost:8080/v1/schema \
-H 'Content-Type: application/json' \
-d '{"classes":[{"class":"Document","vectorizer":"none","properties":[{"name":"content","dataType":["text"]}]}]}'
写入对象:
curl -X POST http://localhost:8080/v1/objects \
-H 'Content-Type: application/json' \
-d '{"class":"Document","properties":{"content":"如何排查磁盘满"},"vector":[0.1,0.2]}'
向量检索:
curl -X POST http://localhost:8080/v1/graphql \
-H 'Content-Type: application/json' \
-d '{"query":"{ Get { Document(nearVector:{vector:[0.1,0.2]}, limit:3){ content _additional { distance } } } }"}'
混合检索:
{
Get {
Document(hybrid: {query: "磁盘满", alpha: 0.5}, limit: 3) {
content
}
}
}
vectorizer: none 但没有提供向量,写入失败。合上页面,先回答,再展开对照。
vectorizer: none 但没有提供向量。alpha,避免 BM25 和向量权重失衡。