dify icon indicating copy to clipboard operation
dify copied to clipboard

Summary Index: data does not be cleared when upload an exists document

Open Yanchongyun opened this issue 6 months ago • 5 comments

Self Checks

  • [x] I have read the Contributing Guide and Language Policy.
  • [x] This is only for bug report, if you would like to ask a question, please head to Discussions.
  • [x] I have searched for existing issues search for existing issues, including closed ones.
  • [x] I confirm that I am using English to submit this report, otherwise it will be closed.
  • [x] 【中文用户 & Non English User】请使用英语提交,否则会被关闭 :)
  • [x] Please do not modify this template :) and fill in all the required fields.

Dify version

1.14.2

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

Step:

  1. Upload a file and turn on [Enable Summary]. Chunk summary is successful created.
  2. Upload same file to same dataset. (From now, Summary setting is disappered)
  3. Summary will not be regenrated at all. But summary data is still in database. (Vector data seems like same)
  4. Regerate summary from button at the top of the page. New summary generated but old data still in the database.

Postion: When upload same file, knowledge_config.duplicate is True and only go into DuplicateDocumentIndexingTask. https://github.com/langgenius/dify/blob/eae44cfecb65957d00cfcb727217652e04be57e1/api/services/dataset_service.py#L2307-L2312

✔️ Expected Behavior

  • Generate new summary when upload same file.
  • Clear old summary pg data.
  • Clear old summary vector data.

❌ Actual Behavior

No response

Yanchongyun avatar Jun 02 '26 08:06 Yanchongyun

This is a confirmed bug. The DuplicateDocumentIndexingTask properly cleans up old document segments (from both PostgreSQL and the vector store) before re-indexing, but it completely skips summary data handling [1].

Specifically, the duplicate indexing flow:

  • ✅ Deletes old DocumentSegment records and their vectors [2]
  • ✅ Re-runs IndexingRunner to reprocess the document [3]
  • ❌ Does not clean up old summary data (PostgreSQL or vector)
  • ❌ Does not call generate_summary_index_task after re-indexing completes

By contrast, the normal document_indexing_task does trigger summary generation after successful indexing [4].

The fix would need two additions to the duplicate document indexing task:

  1. Before re-indexing: Call SummaryIndexService.delete_summaries_for_segments() [5] to clean up old summary records and their vectors for the segments being deleted.

  2. After re-indexing succeeds: Add the same conditional logic from document_indexing_task to queue generate_summary_index_task.delay() — checking that the dataset uses high-quality indexing, has summary_index_setting enabled, and the document has need_summary=True.

It's worth noting that a very similar issue was reported for the document_indexing_update_task (updating documents via service API) in #35950 — both stem from the same root cause: the summary index feature was added to the initial indexing flow but the duplicate/update flows were never updated accordingly.

To reply, just mention @dosu.


Docs are dead. Just use Dosu.

Leave Feedback Ask Dosu about dify

dosubot[bot] avatar Jun 02 '26 08:06 dosubot[bot]

I've submitted a PR #36964 to fix this issue. Looking forward to review!

shifang0511 avatar Jun 03 '26 02:06 shifang0511

Hi, @Yanchongyun. I'm Dosu, and I'm helping the dify team manage their backlog and am marking this issue as stale.

Issue Summary

  • In Dify 1.14.2, re-uploading the same document to the same dataset does not regenerate the summary index.
  • The stale summary data remains in both PostgreSQL and the vector store after re-indexing.
  • The bug appears to be in DuplicateDocumentIndexingTask: it removes old document segments and re-indexes them, but does not clean up summary data or trigger summary regeneration.
  • A fix has been proposed, and PR #36964 was noted as submitted to address the issue.

Next Steps

  • Please confirm whether this issue is still relevant on the latest version of the dify repository.
  • If it is still reproducible, you can keep the discussion open by commenting here; otherwise, this issue will be automatically closed in 15 days.

Thanks for your understanding and contribution.

dosubot[bot] avatar Jul 04 '26 16:07 dosubot[bot]

I'd like to work on this issue. The DuplicateDocumentIndexingTask doesn't clean up old summary data (PG rows + vector embeddings) when a duplicate file is uploaded. Plan to add cleanup logic in the duplicate document indexing path.

EvanYao826 avatar Jul 07 '26 00:07 EvanYao826

Hi, @Yanchongyun. I'm Dosu, and I'm helping the dify team manage their backlog and am marking this issue as stale.

Issue Summary

  • You reported that re-uploading the same file to the same dataset is treated as a duplicate, which skips the normal indexing flow.
  • As a result, the document summary is not regenerated, and the old summary remains in PostgreSQL and the vector store even after manual regeneration.
  • The bug was confirmed in DuplicateDocumentIndexingTask, which re-indexes duplicate documents but does not clean up or re-queue summary generation like the standard path.
  • A fix was mentioned in PR #36964, and there was also interest in adding summary cleanup to the duplicate document indexing flow.

Next Steps

  • Please let us know if this still reproduces on the latest version of the dify repository.
  • If it is still relevant, you can keep the discussion open by commenting here; otherwise, this issue will be automatically closed in 15 days.

Thanks for your understanding and contribution.

dosubot[bot] avatar Aug 07 '26 16:08 dosubot[bot]