How to Fix Knowledge Base Vector Search After Upgrading Dify | Dify 升级后知识库向量检索报错的修复方法
Problem | 问题
After upgrading Dify (e.g., from 1.8.x/1.10.x to 1.11.0+), you may encounter this error when testing knowledge base retrieval:
升级 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[].
Root Cause | 根本原因
English: This is caused by a Weaviate schema format change. Old knowledge bases use vectorIndexConfig at the top level, but newer Dify versions expect vectorConfig.default. This mismatch breaks vector search.
中文: 这是由 Weaviate schema 格式变更引起的。旧知识库在顶层使用 vectorIndexConfig,但新版 Dify 期望 vectorConfig.default 格式。这种不匹配导致向量搜索失败。
Solution | 解决方案
I’ve created a Python script to batch fix this issue:
我创建了一个 Python 脚本来批量修复此问题:
GitHub Repository | 仓库地址
Quick Start | 快速开始
Step 1: Download and copy script | 下载并复制脚本
# Download | 下载
curl -o /tmp/batch_fix_weaviate.py https://raw.githubusercontent.com/yupoet/dify-weaviate-fix/main/batch_fix_weaviate.py
# Copy to container | 复制到容器
docker cp /tmp/batch_fix_weaviate.py docker-api-1:/tmp/
Step 2: Scan affected collections | 扫描受影响的 collections
docker exec docker-api-1 python /tmp/batch_fix_weaviate.py scan
Step 3: Fix all affected collections | 修复所有受影响的 collections
docker exec -it docker-api-1 python /tmp/batch_fix_weaviate.py fix
Step 4: Re-embed in Dify | 在 Dify 中重新嵌入
English: For each affected knowledge base, go to Settings → Embedding Model, switch to a different model, save, then switch back and save again. This forces re-embedding.
中文: 对每个受影响的知识库,进入 设置 → Embedding 模型,切换到另一个模型并保存,然后切换回原模型再保存。这会强制重新嵌入。
Available Commands | 可用命令
| Command | Description | 说明 |
|---|---|---|
scan |
List collections needing fix | 列出需要修复的 collections |
dry-run |
Simulate fix (no changes) | 模拟修复(不实际执行) |
fix |
Fix all affected collections | 修复所有受影响的 collections |
fix-one <name> |
Fix single collection | 修复单个 collection |
cleanup |
Remove orphaned collections | 删除孤立的 collections |
list-names |
Show dataset names | 显示知识库名称 |
Environment Variables | 环境变量
| Variable | Default | Description | 说明 |
|---|---|---|---|
WEAVIATE_ENDPOINT |
http://weaviate:8080 |
Weaviate URL | Weaviate 地址 |
WEAVIATE_API_KEY |
(empty) | API key | API 密钥 |
Tested With | 测试环境
-
Dify 1.11.0
-
Weaviate 1.27.0
Full Documentation | 完整文档
If this helped you, please
the repository!
如果对你有帮助,请给仓库点个
!