Skip to content

Summary Index retrieval is completely broken on Weaviate (and partially broken on all vector DBs) #34884

Closed

Description

@ynomoto-kao

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

  1. Create a dataset with Summary Index enabled using Weaviate as the vector DB
  2. Upload a document and wait for summary generation and vectorization to complete
  3. Verify summaries are stored in Weaviate (they are — generation/storage works correctly)
  4. Search with a query that closely matches the summary text
  5. 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 mismatch

This 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:

Environment: Weaviate 1.27.0, PostgreSQL, text-embedding-3-large

Activity

  1. added
    🐞 bug
    👻 feat:rag
    on Apr 10, 2026
  2. dosubot commented on Apr 10, 2026

    @dosubot

    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 attributes list in Vector.__init__ only contains ["doc_id", "dataset_id", "document_id", "doc_hash", "doc_type"] [1], missing both is_summary and original_chunk_id. Since Weaviate's search_by_vector uses this list as return_properties [2], those fields are never returned, causing is_summary to always default to False in retrieval_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.id is defined with StringUUID [4], which always converts to str via process_result_value [5]. Since original_chunk_id is also set from segment.id (a str) in summary_index_service.py [6], both sides of the lookup should be strings in practice. That said, adding explicit str() conversion as you suggested is good defensive programming — document.metadata is typed as dict[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.

    Leave Feedback Ask Dosu about dify

  3. self-assigned this
    on Apr 10, 2026
  4. bangjiehan commented on Apr 10, 2026

    @bangjiehan
    Contributor

    I’ve been wondering about the purpose of this summarization function, only to find out it was broken all along.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

🐞 bug👻 feat:rag

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions