Repository navigation
Description
Self Checks
- I have read the Contributing Guide and Language Policy.
- This is only for bug report, if you would like to ask a question, please head to Discussions.
- I have searched for existing issues search for existing issues, including closed ones.
- I confirm that I am using English to submit this report, otherwise it will be closed.
- 【中文用户 & Non English User】请使用英语提交,否则会被关闭 :)
- Please do not modify this template :) and fill in all the required fields.
Dify version
1.13.3
Cloud or Self Hosted
Self Hosted (Docker)
Steps to reproduce
- Create a dataset with Summary Index enabled using Weaviate as the vector DB
- Upload a document and wait for summary generation and vectorization to complete
- Verify summaries are stored in Weaviate (they are — generation/storage works correctly)
- Search with a query that closely matches the summary text
- Observe that summary-based retrieval does not enhance results — summary vectors consume top_k slots and silently disappear
Two independent bugs prevent Summary Index retrieval from functioning:
Bug 1: is_summary and original_chunk_id missing from Weaviate return properties
File: api/core/rag/datasource/vdb/vector_factory.py, line 41
The default attributes list used as Weaviate return_properties does not include is_summary or original_chunk_id:
class Vector:
def __init__(self, dataset: Dataset, attributes: list | None = None):
if attributes is None:
attributes = ["doc_id", "dataset_id", "document_id", "doc_hash", "doc_type"]
# Missing: "is_summary", "original_chunk_id"However, summary_index_service.py stores these fields when vectorizing summaries (line 211-220):
summary_document = Document(
page_content=summary_content,
metadata={
"doc_id": summary_index_node_id,
"original_chunk_id": segment.id, # ← stored but never retrieved
"is_summary": True, # ← stored but never retrieved
...
},
)In retrieval_service.py (line 464), is_summary always defaults to False, so summary vectors are treated as normal chunks. Since the summary's doc_id doesn't match any DocumentSegment.index_node_id, the DB lookup returns nothing and the summary is silently dropped. The summary consumed a top_k slot but produced nothing.
This is Weaviate-specific — other vector DBs return all metadata by default.
Bug 2: str vs uuid.UUID type mismatch in score inheritance
File: api/core/rag/datasource/retrieval_service.py, lines 469, 649-652
When a summary hits, its score is stored with the parent chunk ID as key (str from metadata):
summary_score_map[original_chunk_id] = summary_score_float # key = "5c5278b0-..."But when inheriting the score to the parent chunk, segment.id is uuid.UUID:
max_score = summary_score_map.get(segment.id, 0.0) # UUID ≠ str → always 0.0
if segment.id not in summary_score_map: # also always True due to type mismatchThis affects all vector DBs. Even if Bug #1 is fixed, summary scores are never inherited to parent chunks.
| Case | Expected score | Actual score |
|---|---|---|
| Only summary hits (0.92) | 0.92 | 0.0 |
| Both summary (0.92) and chunk (0.85) hit | max(0.92, 0.85) = 0.92 | 0.85 |
✔️ Expected Behavior
When a summary vector matches the user's query, the original parent chunk should be returned with the higher of the summary's score and the chunk's own score (if both hit). This enables retrieval of contextually relevant chunks that might not match the query directly.
❌ Actual Behavior
Summary Index retrieval is completely non-functional:
| Vector DB | Bug 1 | Bug 2 | Net Effect |
|---|---|---|---|
| Weaviate | ❌ Affected | ❌ Affected (hidden by 1) | Summary vectors consume top_k slots and silently disappear |
| Qdrant, pgvector, etc. | ✅ Not affected | ❌ Affected | Summary score never inherited — parent chunks get 0.0 or only their own score |
Suggested fixes:
Bug 1 — Add missing properties to default attributes:
attributes = ["doc_id", "dataset_id", "document_id", "doc_hash", "doc_type",
"is_summary", "original_chunk_id"]Bug 2 — Normalize to str consistently:
original_chunk_id = str(document.metadata.get("original_chunk_id"))
max_score = summary_score_map.get(str(segment.id), 0.0)Additional context:
- These bugs have been present since Summary Index was introduced in 1.12.0 (PR feat: Add summary index for knowledge. #31625, feat: Summary index for knowledge. #31719)
- Related but distinct: Issue Summary Index succeeds in logs but API returns summary: null (GET /segments/{segment_id} and POST /datasets/{id}/retrieve) on Dify 1.13.0 with PostgreSQL + Weaviate #34202 / PR fix: enrich Service API segment responses with summary content #34221 fixed Service API not returning summary content — that was an API serialization issue, not a retrieval logic issue
- Summary generation and storage work correctly; only the retrieval-time score boosting is broken
Environment: Weaviate 1.27.0, PostgreSQL, text-embedding-3-large
Activity
dosubot commentedon Apr 10, 2026
Hi @ynomoto-kao! I'm Dosu and I’m helping the dify team.
Great bug report — I verified both issues against the current codebase.
Bug 1 is confirmed. The default
attributeslist inVector.__init__only contains["doc_id", "dataset_id", "document_id", "doc_hash", "doc_type"][1], missing bothis_summaryandoriginal_chunk_id. Since Weaviate'ssearch_by_vectoruses this list asreturn_properties[2], those fields are never returned, causingis_summaryto always default toFalseinretrieval_service.py[3]. Your suggested fix of adding both fields to the default attributes list is the right approach.Bug 2 is partially confirmed, but less severe than described.
segment.idis defined withStringUUID[4], which always converts tostrviaprocess_result_value[5]. Sinceoriginal_chunk_idis also set fromsegment.id(astr) insummary_index_service.py[6], both sides of the lookup should be strings in practice. That said, adding explicitstr()conversion as you suggested is good defensive programming —document.metadatais typed asdict[str, Any], so there's no compile-time guarantee the value stays a string after round-tripping through a vector DB.No existing PRs address either issue. The related PR #31445 fixed other summary index problems but didn't touch the default attributes list.
To reply, just mention @dosu.
Docs are dead. Just use Dosu.
bangjiehan commentedon Apr 10, 2026
I’ve been wondering about the purpose of this summarization function, only to find out it was broken all along.
fix(rag): include is_summary and original_chunk_id in default vector …