如何修复 Dify 升级后知识库向量检索报错 | Dify 升级后知识库向量检索报错的修复方法
问题
升级 Dify(例如从 1.8.x/1.10.x 升级到 1.11.0+)后,测试知识库检索时可能遇到以下错误:
Query call with protocol GRPC search failed with message extract target vectors: class
Vector_index_xxx_Node does not have named vector default configured.
Available named vectors map[].
根本原因
中文: 这是由 Weaviate schema 格式变更引起的。旧知识库在顶层使用 vectorIndexConfig,但新版 Dify 期望 vectorConfig.default 格式。这种不匹配导致向量搜索失败。
解决方案
我创建了一个 Python 脚本来批量修复此问题:
仓库地址
快速开始
步骤 1:下载并复制脚本
# 下载
curl -o /tmp/batch_fix_weaviate.py https://raw.githubusercontent.com/yupoet/dify-weaviate-fix/main/batch_fix_weaviate.py
# 复制到容器
docker cp /tmp/batch_fix_weaviate.py docker-api-1:/tmp/
步骤 2:扫描受影响的 collections
docker exec docker-api-1 python /tmp/batch_fix_weaviate.py scan
步骤 3:修复所有受影响的 collections
docker exec -it docker-api-1 python /tmp/batch_fix_weaviate.py fix
步骤 4:在 Dify 中重新嵌入
中文: 对每个受影响的知识库,进入 设置 → Embedding 模型,切换到另一个模型并保存,然后切换回原模型再保存。这会强制重新嵌入。
可用命令
| 命令 | 说明 |
|---|---|
scan |
列出需要修复的 collections |
dry-run |
模拟修复(不实际执行) |
fix |
修复所有受影响的 collections |
fix-one <name> |
修复单个 collection |
cleanup |
删除孤立的 collections |
list-names |
显示知识库名称 |
环境变量
| 变量 | 默认值 | 说明 |
|---|---|---|
WEAVIATE_ENDPOINT |
http://weaviate:8080 |
Weaviate 地址 |
WEAVIATE_API_KEY |
(空) | API 密钥 |
测试环境
- Dify 1.11.0
- Weaviate 1.27.0
完整文档
如果对你有帮助,请给仓库点个
!