The RAG recall did not meet expectations based on the configuration #21883

Open
opened 2026-02-21 20:14:43 -05:00 by yindo · 17 comments
Owner

Originally created by @hutao86 on GitHub (Jan 25, 2026).

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

v1.9.2

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

My knowledge base configuration is set to a high-quality index type, with a mixed retrieval setting, and no score threshold is set. Additionally, the topk setting is set to 10. There are more than 10 segments in my knowledge base. Of course, I have maintained the same configuration in the workflow. After initially importing the knowledge base and executing the knowledge base retrieval in the workflow, the recall function worked normally and returned the expected 10 records. However, after deleting several entries and adding some new ones to the knowledge base, the returned results no longer matched the set limit of 10 entries. The number of returned results was not fixed, sometimes returning one, sometimes two, sometimes five... I have also read related comments suggesting that I should wait for a period of time. But several days have passed, and the results still do not return as set. What could be the reason? Does the rerank model itself filter based on the threshold?

Image Image

✔️ Expected Behavior

It is expected to be consistent with the set topk, or relevant parameters should be provided

Actual Behavior

No response

Originally created by @hutao86 on GitHub (Jan 25, 2026). ### Self Checks - [x] I have read the [Contributing Guide](https://github.com/langgenius/dify/blob/main/CONTRIBUTING.md) and [Language Policy](https://github.com/langgenius/dify/issues/1542). - [x] This is only for bug report, if you would like to ask a question, please head to [Discussions](https://github.com/langgenius/dify/discussions/categories/general). - [x] I have searched for existing issues [search for existing issues](https://github.com/langgenius/dify/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 v1.9.2 ### Cloud or Self Hosted Self Hosted (Docker) ### Steps to reproduce My knowledge base configuration is set to a high-quality index type, with a mixed retrieval setting, and no score threshold is set. Additionally, the topk setting is set to 10. There are more than 10 segments in my knowledge base. Of course, I have maintained the same configuration in the workflow. After initially importing the knowledge base and executing the knowledge base retrieval in the workflow, the recall function worked normally and returned the expected 10 records. However, after deleting several entries and adding some new ones to the knowledge base, the returned results no longer matched the set limit of 10 entries. The number of returned results was not fixed, sometimes returning one, sometimes two, sometimes five... I have also read related comments suggesting that I should wait for a period of time. But several days have passed, and the results still do not return as set. What could be the reason? Does the rerank model itself filter based on the threshold? <img width="962" height="802" alt="Image" src="https://github.com/user-attachments/assets/348ac10d-cb2a-4fec-be75-1965ffd843e3" /> <img width="1305" height="580" alt="Image" src="https://github.com/user-attachments/assets/db04c82d-97d8-4ba0-8063-0257fe3e7bef" /> ### ✔️ Expected Behavior It is expected to be consistent with the set topk, or relevant parameters should be provided ### ❌ Actual Behavior _No response_
yindo added the 👻 feat:rag label 2026-02-21 20:14:43 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Jan 25, 2026):

The number of results returned can be less than your configured topk due to how Dify applies reranking and filtering. Even with score threshold set to 0, the rerank model only includes documents with scores ≥ 0—so any with negative or missing scores are filtered out. After reranking, results are sorted by score and truncated to topk, but if not enough documents meet the criteria, you’ll get fewer than requested. Hybrid search and deduplication can further reduce the count, especially after updates or if there are duplicate/low-scoring segments.

If you recently modified the knowledge base, temporary inconsistencies can also occur if the index hasn’t fully synchronized. To troubleshoot: try reindexing the knowledge base, restarting services, and check logs for indexing or retrieval errors. If the issue persists, collect logs and config details for further investigation.
Reference: rerank and topk logic
Reference: retrieval pipeline and filtering

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other

Chat with Dosu Open in Cursor Join Discord Share on X

@dosubot[bot] commented on GitHub (Jan 25, 2026): <!-- Answer --> The number of results returned can be less than your configured topk due to how Dify applies reranking and filtering. Even with score threshold set to 0, the rerank model only includes documents with scores ≥ 0—so any with negative or missing scores are filtered out. After reranking, results are sorted by score and truncated to topk, but if not enough documents meet the criteria, you’ll get fewer than requested. Hybrid search and deduplication can further reduce the count, especially after updates or if there are duplicate/low-scoring segments. If you recently modified the knowledge base, temporary inconsistencies can also occur if the index hasn’t fully synchronized. To troubleshoot: try reindexing the knowledge base, restarting services, and check logs for indexing or retrieval errors. If the issue persists, collect logs and config details for further investigation. [Reference: rerank and topk logic](https://github.com/langgenius/dify/blob/9d38af6d99d6a2f2b64004895d154ae5d59ca64d/api/core/rag/rerank/rerank_model.py#L15-L107) [Reference: retrieval pipeline and filtering](https://github.com/langgenius/dify/blob/9d38af6d99d6a2f2b64004895d154ae5d59ca64d/api/core/rag/retrieval/dataset_retrieval.py#L129-L1514) <!-- Dosu Comment Footer --> *To reply, just mention [@dosu](https://go.dosu.dev/dosubot).* --- <sup>How did I do? [Good](https://app.dosu.dev/response-feedback/0800eacf-d9da-4917-b9b9-9ff869a216a8?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/0800eacf-d9da-4917-b9b9-9ff869a216a8?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/0800eacf-d9da-4917-b9b9-9ff869a216a8?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/0800eacf-d9da-4917-b9b9-9ff869a216a8?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/0800eacf-d9da-4917-b9b9-9ff869a216a8?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/0800eacf-d9da-4917-b9b9-9ff869a216a8?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/0800eacf-d9da-4917-b9b9-9ff869a216a8?feedback_type=other)</sup> [![Chat with Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/6088a4f4-073a-43f3-b3d4-4f06fb0c05a0/ask?utm_source=github)&nbsp;[![Open in Cursor](https://dosu.dev/dosu-in-cursor.svg)](https://cursor.com/link/prompt?text=The%20number%20of%20results%20returned%20can%20be%20less%20than%20your%20configured%20topk%20due%20to%20how%20Dify%20applies%20reranking%20and%20filtering.%20Even%20with%20score%20threshold%20set%20to%200%2C%20the%20rerank%20model%20only%20includes%20documents%20with%20scores%20%E2%89%A5%200%E2%80%94so%20any%20with%20negative%20or%20missing%20scores%20are%20filtered%20out.%20After%20reranking%2C%20results%20are%20sorted%20by%20score%20and%20truncated%20to%20topk%2C%20but%20if%20not%20enough%20documents%20meet%20the%20criteria%2C%20you%E2%80%99ll%20get%20fewer%20than%20requested.%20Hybrid%20search%20and%20deduplication%20can%20further%20reduce%20the%20count%2C%20especially%20after%20updates%20or%20if%20there%20are%20duplicate/low-scoring%20segments.%20%0A%0AIf%20you%20recently%20modified%20the%20knowledge%20base%2C%20temporary%20inconsistencies%20can%20also%20occur%20if%20the%20index%20hasn%E2%80%99t%20fully%20synchronized.%20To%20troubleshoot%3A%20try%20reindexing%20the%20knowledge%20base%2C%20restarting%20services%2C%20and%20check%20logs%20for%20indexing%20or%20retrieval%20errors.%20If%20the%20issue%20persists%2C%20collect%20logs%20and%20config%20details%20for%20further%20investigation.%20%20%0A%5BReference%3A%20rerank%20and%20topk%20logic%5D%28https%3A//github.com/langgenius/dify/blob/9d38af6d99d6a2f2b64004895d154ae5d59ca64d/api/core/rag/rerank/rerank_model.py%23L15-L107%29%20%20%0A%5BReference%3A%20retrieval%20pipeline%20and%20filtering%5D%28https%3A//github.com/langgenius/dify/blob/9d38af6d99d6a2f2b64004895d154ae5d59ca64d/api/core/rag/retrieval/dataset_retrieval.py%23L129-L1514%29)&nbsp;[![Join Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share on X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/langgenius/dify/issues/31505)
Author
Owner

@hutao86 commented on GitHub (Jan 25, 2026):

I exported the latest knowledge base and then re-imported it, but the recall results were the same as the settings. How should I explain this? The contents of the two knowledge bases are exactly the same, and the settings are also the same, but the number of recalls from the previous one was incorrect.

@hutao86 commented on GitHub (Jan 25, 2026): I exported the latest knowledge base and then re-imported it, but the recall results were the same as the settings. How should I explain this? The contents of the two knowledge bases are exactly the same, and the settings are also the same, but the number of recalls from the previous one was incorrect.
Author
Owner

@dosubot[bot] commented on GitHub (Jan 25, 2026):

This happens because incremental updates (like deleting or adding entries) may not fully clean or rebuild the internal index, which can leave behind stale or inconsistent data—even if the visible content and settings look correct. As a result, retrieval can return fewer or inconsistent results than your configured topk, despite everything appearing aligned in the UI. When you export and re-import the knowledge base, Dify triggers a full re-index and regenerates all embeddings, which rebuilds the index from scratch and resolves any hidden inconsistencies. This restores the expected recall behavior, so the number of results matches your topk setting again—even though the content and settings are the same as before. This behavior is confirmed by both user reports and the backend code for indexing and retrieval tasks (reference, reference).

If you see this issue again after incremental changes, running a full re-index or re-import is the most reliable way to restore consistency.

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other

Chat with Dosu Open in Cursor Join Discord Share on X

@dosubot[bot] commented on GitHub (Jan 25, 2026): <!-- Answer --> This happens because incremental updates (like deleting or adding entries) may not fully clean or rebuild the internal index, which can leave behind stale or inconsistent data—even if the visible content and settings look correct. As a result, retrieval can return fewer or inconsistent results than your configured topk, despite everything appearing aligned in the UI. When you export and re-import the knowledge base, Dify triggers a full re-index and regenerates all embeddings, which rebuilds the index from scratch and resolves any hidden inconsistencies. This restores the expected recall behavior, so the number of results matches your topk setting again—even though the content and settings are the same as before. This behavior is confirmed by both user reports and the backend code for indexing and retrieval tasks ([reference](https://github.com/langgenius/dify/blob/9d38af6d99d6a2f2b64004895d154ae5d59ca64d/api/tasks/deal_dataset_index_update_task.py#L16-L198), [reference](https://github.com/langgenius/dify/issues/27046)). If you see this issue again after incremental changes, running a full re-index or re-import is the most reliable way to restore consistency. <!-- Dosu Comment Footer --> *To reply, just mention [@dosu](https://go.dosu.dev/dosubot).* --- <sup>How did I do? [Good](https://app.dosu.dev/response-feedback/f3aed4ce-fd53-477a-ad80-632abfd67ba7?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/f3aed4ce-fd53-477a-ad80-632abfd67ba7?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/f3aed4ce-fd53-477a-ad80-632abfd67ba7?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/f3aed4ce-fd53-477a-ad80-632abfd67ba7?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/f3aed4ce-fd53-477a-ad80-632abfd67ba7?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/f3aed4ce-fd53-477a-ad80-632abfd67ba7?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/f3aed4ce-fd53-477a-ad80-632abfd67ba7?feedback_type=other)</sup> [![Chat with Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/6088a4f4-073a-43f3-b3d4-4f06fb0c05a0/ask?utm_source=github)&nbsp;[![Open in Cursor](https://dosu.dev/dosu-in-cursor.svg)](https://cursor.com/link/prompt?text=This%20happens%20because%20incremental%20updates%20%28like%20deleting%20or%20adding%20entries%29%20may%20not%20fully%20clean%20or%20rebuild%20the%20internal%20index%2C%20which%20can%20leave%20behind%20stale%20or%20inconsistent%20data%E2%80%94even%20if%20the%20visible%20content%20and%20settings%20look%20correct.%20As%20a%20result%2C%20retrieval%20can%20return%20fewer%20or%20inconsistent%20results%20than%20your%20configured%20topk%2C%20despite%20everything%20appearing%20aligned%20in%20the%20UI.%20When%20you%20export%20and%20re-import%20the%20knowledge%20base%2C%20Dify%20triggers%20a%20full%20re-index%20and%20regenerates%20all%20embeddings%2C%20which%20rebuilds%20the%20index%20from%20scratch%20and%20resolves%20any%20hidden%20inconsistencies.%20This%20restores%20the%20expected%20recall%20behavior%2C%20so%20the%20number%20of%20results%20matches%20your%20topk%20setting%20again%E2%80%94even%20though%20the%20content%20and%20settings%20are%20the%20same%20as%20before.%20This%20behavior%20is%20confirmed%20by%20both%20user%20reports%20and%20the%20backend%20code%20for%20indexing%20and%20retrieval%20tasks%20%28%5Breference%5D%28https%3A//github.com/langgenius/dify/blob/9d38af6d99d6a2f2b64004895d154ae5d59ca64d/api/tasks/deal_dataset_index_update_task.py%23L16-L198%29%2C%20%5Breference%5D%28https%3A//github.com/langgenius/dify/issues/27046%29%29.%20%0A%0AIf%20you%20see%20this%20issue%20again%20after%20incremental%20changes%2C%20running%20a%20full%20re-index%20or%20re-import%20is%20the%20most%20reliable%20way%20to%20restore%20consistency.)&nbsp;[![Join Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share on X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/langgenius/dify/issues/31505)
Author
Owner

@hutao86 commented on GitHub (Jan 25, 2026):

How to perform reindexing

@hutao86 commented on GitHub (Jan 25, 2026): How to perform reindexing
Author
Owner

@dosubot[bot] commented on GitHub (Jan 25, 2026):

There are several ways to trigger reindexing in Dify (self-hosted, Docker):

  1. Export and Re-import: Export your knowledge base and re-import it. This triggers a full reindex and regenerates all embeddings, which is the most reliable way to rebuild the index from scratch and resolve inconsistencies. This is what you already did, and it matches the backend logic for a full reindex [source].

  2. Change Embedding Model: In the knowledge base settings, switch the embedding model to a different one, save, then (optionally) switch back. This forces Dify to reindex all documents. Be aware this may cause downtime while reindexing completes, especially for large datasets [source].

  3. Disable and Re-enable Files: For smaller knowledge bases, you can disable and then re-enable all files in the knowledge base. This triggers reindexing for those documents. Don’t do this too quickly, or you may see “document is being indexed, please try again later” errors [source].

  4. API/Script: For large-scale or automated reindexing, use the API. There’s no single “full reindex” endpoint, but you can:

    • Trigger reindex for individual documents:
      POST /datasets/<dataset_id>/retry with a JSON body specifying document_ids [source].
    • For pipeline workflows, you can POST the pipeline graph to /rag/pipelines/<pipeline_id>/workflows/draft to refresh the pipeline [source].
  5. Manual (per-document) in UI: In the document detail view, use the “regenerate” or “reindex” option for individual documents or segments. There is no “one-click” full KB reindex button in the UI [source].

Caveats:

  • After deleting or disabling files, or after a re-import, wait for all background indexing tasks to finish. The UI may show “available” before indexing is truly complete, so recall may not work instantly [source].
  • Avoid disabling and deleting files in quick succession, as this can queue redundant background jobs and cause delays [source].
  • For very large KBs, consider scripting the process and adjusting the DATASET_MAX_SEGMENTS_PER_REQUEST environment variable if you hit segment limits [source].

If you want the most reliable, full reindex: export and re-import your KB, or change the embedding model to force a rebuild. For smaller or targeted fixes, use the disable/enable or per-document API/UI methods.

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other

Chat with Dosu Open in Cursor Join Discord Share on X

@dosubot[bot] commented on GitHub (Jan 25, 2026): <!-- Answer --> There are several ways to trigger reindexing in Dify (self-hosted, Docker): 1. **Export and Re-import**: Export your knowledge base and re-import it. This triggers a full reindex and regenerates all embeddings, which is the most reliable way to rebuild the index from scratch and resolve inconsistencies. This is what you already did, and it matches the backend logic for a full reindex [[source]](https://github.com/langgenius/dify/issues/29243). 2. **Change Embedding Model**: In the knowledge base settings, switch the embedding model to a different one, save, then (optionally) switch back. This forces Dify to reindex all documents. Be aware this may cause downtime while reindexing completes, especially for large datasets [[source]](https://github.com/langgenius/dify/issues/29243). 3. **Disable and Re-enable Files**: For smaller knowledge bases, you can disable and then re-enable all files in the knowledge base. This triggers reindexing for those documents. Don’t do this too quickly, or you may see “document is being indexed, please try again later” errors [[source]](https://github.com/langgenius/dify/issues/20422). 4. **API/Script**: For large-scale or automated reindexing, use the API. There’s no single “full reindex” endpoint, but you can: - Trigger reindex for individual documents: `POST /datasets/<dataset_id>/retry` with a JSON body specifying `document_ids` [[source]](https://github.com/langgenius/dify/discussions/26691). - For pipeline workflows, you can POST the pipeline graph to `/rag/pipelines/<pipeline_id>/workflows/draft` to refresh the pipeline [[source]](https://github.com/langgenius/dify/discussions/26691). 5. **Manual (per-document) in UI**: In the document detail view, use the “regenerate” or “reindex” option for individual documents or segments. There is no “one-click” full KB reindex button in the UI [[source]](https://github.com/langgenius/dify/discussions/28216). **Caveats:** - After deleting or disabling files, or after a re-import, wait for all background indexing tasks to finish. The UI may show “available” before indexing is truly complete, so recall may not work instantly [[source]](https://github.com/langgenius/dify/issues/29198). - Avoid disabling and deleting files in quick succession, as this can queue redundant background jobs and cause delays [[source]](https://github.com/langgenius/dify/issues/29198). - For very large KBs, consider scripting the process and adjusting the `DATASET_MAX_SEGMENTS_PER_REQUEST` environment variable if you hit segment limits [[source]](https://github.com/langgenius/dify/discussions/28216). If you want the most reliable, full reindex: export and re-import your KB, or change the embedding model to force a rebuild. For smaller or targeted fixes, use the disable/enable or per-document API/UI methods. <!-- Dosu Comment Footer --> *To reply, just mention [@dosu](https://go.dosu.dev/dosubot).* --- <sup>How did I do? [Good](https://app.dosu.dev/response-feedback/5e9e7aaf-38bd-4867-978a-717baa9ac324?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/5e9e7aaf-38bd-4867-978a-717baa9ac324?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/5e9e7aaf-38bd-4867-978a-717baa9ac324?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/5e9e7aaf-38bd-4867-978a-717baa9ac324?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/5e9e7aaf-38bd-4867-978a-717baa9ac324?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/5e9e7aaf-38bd-4867-978a-717baa9ac324?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/5e9e7aaf-38bd-4867-978a-717baa9ac324?feedback_type=other)</sup> [![Chat with Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/6088a4f4-073a-43f3-b3d4-4f06fb0c05a0/ask?utm_source=github)&nbsp;[![Open in Cursor](https://dosu.dev/dosu-in-cursor.svg)](https://cursor.com/link/prompt?text=There%20are%20several%20ways%20to%20trigger%20reindexing%20in%20Dify%20%28self-hosted%2C%20Docker%29%3A%0A%0A1.%20%2A%2AExport%20and%20Re-import%2A%2A%3A%20Export%20your%20knowledge%20base%20and%20re-import%20it.%20This%20triggers%20a%20full%20reindex%20and%20regenerates%20all%20embeddings%2C%20which%20is%20the%20most%20reliable%20way%20to%20rebuild%20the%20index%20from%20scratch%20and%20resolve%20inconsistencies.%20This%20is%20what%20you%20already%20did%2C%20and%20it%20matches%20the%20backend%20logic%20for%20a%20full%20reindex%20%5B%5Bsource%5D%5D%28https%3A//github.com/langgenius/dify/issues/29243%29.%0A%0A2.%20%2A%2AChange%20Embedding%20Model%2A%2A%3A%20In%20the%20knowledge%20base%20settings%2C%20switch%20the%20embedding%20model%20to%20a%20different%20one%2C%20save%2C%20then%20%28optionally%29%20switch%20back.%20This%20forces%20Dify%20to%20reindex%20all%20documents.%20Be%20aware%20this%20may%20cause%20downtime%20while%20reindexing%20completes%2C%20especially%20for%20large%20datasets%20%5B%5Bsource%5D%5D%28https%3A//github.com/langgenius/dify/issues/29243%29.%0A%0A3.%20%2A%2ADisable%20and%20Re-enable%20Files%2A%2A%3A%20For%20smaller%20knowledge%20bases%2C%20you%20can%20disable%20and%20then%20re-enable%20all%20files%20in%20the%20knowledge%20base.%20This%20triggers%20reindexing%20for%20those%20documents.%20Don%E2%80%99t%20do%20this%20too%20quickly%2C%20or%20you%20may%20see%20%E2%80%9Cdocument%20is%20being%20indexed%2C%20please%20try%20again%20later%E2%80%9D%20errors%20%5B%5Bsource%5D%5D%28https%3A//github.com/langgenius/dify/issues/20422%29.%0A%0A4.%20%2A%2AAPI/Script%2A%2A%3A%20For%20large-scale%20or%20automated%20reindexing%2C%20use%20the%20API.%20There%E2%80%99s%20no%20single%20%E2%80%9Cfull%20reindex%E2%80%9D%20endpoint%2C%20but%20you%20can%3A%0A%20%20%20-%20Trigger%20reindex%20for%20individual%20documents%3A%20%20%0A%20%20%20%20%20%60POST%20/datasets/%3Cdataset_id%3E/retry%60%20with%20a%20JSON%20body%20specifying%20%60document_ids%60%20%5B%5Bsource%5D%5D%28https%3A//github.com/langgenius/dify/discussions/26691%29.%0A%20%20%20-%20For%20pipeline%20workflows%2C%20you%20can%20POST%20the%20pipeline%20graph%20to%20%60/rag/pipelines/%3Cpipeline_id%3E/workflows/draft%60%20to%20refresh%20the%20pipeline%20%5B%5Bsource%5D%5D%28https%3A//github.com/langgenius/dify/discussions/26691%29.%0A%0A5.%20%2A%2AManual%20%28per-document%29%20in%20UI%2A%2A%3A%20In%20the%20document%20detail%20view%2C%20use%20the%20%E2%80%9Cregenerate%E2%80%9D%20or%20%E2%80%9Creindex%E2%80%9D%20option%20for%20individual%20documents%20or%20segments.%20There%20is%20no%20%E2%80%9Cone-click%E2%80%9D%20full%20KB%20reindex%20button%20in%20the%20UI%20%5B%5Bsource%5D%5D%28https%3A//github.com/langgenius/dify/discussions/28216%29.%0A%0A%2A%2ACaveats%3A%2A%2A%20%20%0A-%20After%20deleting%20or%20disabling%20files%2C%20or%20after%20a%20re-import%2C%20wait%20for%20all%20background%20indexing%20tasks%20to%20finish.%20The%20UI%20may%20show%20%E2%80%9Cavailable%E2%80%9D%20before%20indexing%20is%20truly%20complete%2C%20so%20recall%20may%20not%20work%20instantly%20%5B%5Bsource%5D%5D%28https%3A//github.com/langgenius/dify/issues/29198%29.%0A-%20Avoid%20disabling%20and%20deleting%20files%20in%20quick%20succession%2C%20as%20this%20can%20queue%20redundant%20background%20jobs%20and%20cause%20delays%20%5B%5Bsource%5D%5D%28https%3A//github.com/langgenius/dify/issues/29198%29.%0A-%20For%20very%20large%20KBs%2C%20consider%20scripting%20the%20process%20and%20adjusting%20the%20%60DATASET_MAX_SEGMENTS_PER_REQUEST%60%20environment%20variable%20if%20you%20hit%20segment%20limits%20%5B%5Bsource%5D%5D%28https%3A//github.com/langgenius/dify/discussions/28216%29.%0A%0AIf%20you%20want%20the%20most%20reliable%2C%20full%20reindex%3A%20export%20and%20re-import%20your%20KB%2C%20or%20change%20the%20embedding%20model%20to%20force%20a%20rebuild.%20For%20smaller%20or%20targeted%20fixes%2C%20use%20the%20disable/enable%20or%20per-document%20API/UI%20methods.)&nbsp;[![Join Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share on X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/langgenius/dify/issues/31505)
Author
Owner

@hutao86 commented on GitHub (Jan 25, 2026):

POST /datasets/<dataset_id>/retry
Content-Type: application/json
Authorization: Bearer <your_token>
{
"document_ids": ["<document_id>"]
}

Should 'your_token' here be a dataset token?

curl -X POST
http://192.168.0.189:80/console/api/datasets/d04b473a-fc66-496b-89f7-94b618b2cff0/retry
-H "Content-Type: application/json"
-H "Authorization: Bearer dataset-JaV4Om9fdEIR6xem2q21ndQB"
-d '{
"document_ids": ["e3cbee9a-edbf-4424-98b7-881a5530342e"]
}'

return result:
{"code":"unauthorized","message":"Invalid token.","status":401}

@hutao86 commented on GitHub (Jan 25, 2026): POST /datasets/<dataset_id>/retry Content-Type: application/json Authorization: Bearer <your_token> { "document_ids": ["<document_id>"] } Should 'your_token' here be a dataset token? curl -X POST \ http://192.168.0.189:80/console/api/datasets/d04b473a-fc66-496b-89f7-94b618b2cff0/retry \ -H "Content-Type: application/json" \ -H "Authorization: Bearer dataset-JaV4Om9fdEIR6xem2q21ndQB" \ -d '{ "document_ids": ["e3cbee9a-edbf-4424-98b7-881a5530342e"] }' return result: {"code":"unauthorized","message":"Invalid token.","status":401}
Author
Owner

@dosubot[bot] commented on GitHub (Jan 25, 2026):

The /datasets/<dataset_id>/retry endpoint does not accept a dataset token (tokens starting with dataset-). That token type is only for read/query operations. For this endpoint, you need a user or API token with owner, editor, or admin permissions on the workspace or dataset. Using a dataset token will always return a 401 Unauthorized error with "Invalid token" because it doesn't have the required privileges for mutation endpoints like /retry [source].

To get a valid token:

  1. Go to the Dify console, open your user profile or team settings, and generate a personal API key (user token) or use an existing one.
  2. Use this token in your Authorization header:
    Authorization: Bearer <your_user_or_api_token>
    
  3. Your curl command should look like:
    curl -X POST http://192.168.0.189:80/console/api/datasets/<dataset_id>/retry \
      -H "Content-Type: application/json" \
      -H "Authorization: Bearer <your_user_or_api_token>" \
      -d '{"document_ids": ["<document_id>"]}'
    

Make sure the user or API token has sufficient permissions (owner/editor/admin) for the dataset. This will allow the /retry call to succeed [source].

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other

Chat with Dosu Open in Cursor Join Discord Share on X

@dosubot[bot] commented on GitHub (Jan 25, 2026): <!-- Answer --> The /datasets/<dataset_id>/retry endpoint does not accept a dataset token (tokens starting with dataset-). That token type is only for read/query operations. For this endpoint, you need a user or API token with owner, editor, or admin permissions on the workspace or dataset. Using a dataset token will always return a 401 Unauthorized error with "Invalid token" because it doesn't have the required privileges for mutation endpoints like /retry [[source](https://github.com/langgenius/dify/issues/28388)]. To get a valid token: 1. Go to the Dify console, open your user profile or team settings, and generate a personal API key (user token) or use an existing one. 2. Use this token in your Authorization header: ``` Authorization: Bearer <your_user_or_api_token> ``` 3. Your curl command should look like: ``` curl -X POST http://192.168.0.189:80/console/api/datasets/<dataset_id>/retry \ -H "Content-Type: application/json" \ -H "Authorization: Bearer <your_user_or_api_token>" \ -d '{"document_ids": ["<document_id>"]}' ``` Make sure the user or API token has sufficient permissions (owner/editor/admin) for the dataset. This will allow the /retry call to succeed [[source](https://github.com/langgenius/dify/discussions/26691)]. <!-- Dosu Comment Footer --> *To reply, just mention [@dosu](https://go.dosu.dev/dosubot).* --- <sup>How did I do? [Good](https://app.dosu.dev/response-feedback/940a94c7-34e4-4799-9eda-058c12fc30a6?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/940a94c7-34e4-4799-9eda-058c12fc30a6?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/940a94c7-34e4-4799-9eda-058c12fc30a6?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/940a94c7-34e4-4799-9eda-058c12fc30a6?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/940a94c7-34e4-4799-9eda-058c12fc30a6?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/940a94c7-34e4-4799-9eda-058c12fc30a6?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/940a94c7-34e4-4799-9eda-058c12fc30a6?feedback_type=other)</sup> [![Chat with Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/6088a4f4-073a-43f3-b3d4-4f06fb0c05a0/ask?utm_source=github)&nbsp;[![Open in Cursor](https://dosu.dev/dosu-in-cursor.svg)](https://cursor.com/link/prompt?text=The%20/datasets/%3Cdataset_id%3E/retry%20endpoint%20does%20not%20accept%20a%20dataset%20token%20%28tokens%20starting%20with%20dataset-%29.%20That%20token%20type%20is%20only%20for%20read/query%20operations.%20For%20this%20endpoint%2C%20you%20need%20a%20user%20or%20API%20token%20with%20owner%2C%20editor%2C%20or%20admin%20permissions%20on%20the%20workspace%20or%20dataset.%20Using%20a%20dataset%20token%20will%20always%20return%20a%20401%20Unauthorized%20error%20with%20%22Invalid%20token%22%20because%20it%20doesn%27t%20have%20the%20required%20privileges%20for%20mutation%20endpoints%20like%20/retry%20%5B%5Bsource%5D%28https%3A//github.com/langgenius/dify/issues/28388%29%5D.%0A%0ATo%20get%20a%20valid%20token%3A%20%20%0A1.%20Go%20to%20the%20Dify%20console%2C%20open%20your%20user%20profile%20or%20team%20settings%2C%20and%20generate%20a%20personal%20API%20key%20%28user%20token%29%20or%20use%20an%20existing%20one.%20%20%0A2.%20Use%20this%20token%20in%20your%20Authorization%20header%3A%20%20%0A%20%20%20%60%60%60%0A%20%20%20Authorization%3A%20Bearer%20%3Cyour_user_or_api_token%3E%0A%20%20%20%60%60%60%0A3.%20Your%20curl%20command%20should%20look%20like%3A%0A%20%20%20%60%60%60%0A%20%20%20curl%20-X%20POST%20http%3A//192.168.0.189%3A80/console/api/datasets/%3Cdataset_id%3E/retry%20%5C%0A%20%20%20%20%20-H%20%22Content-Type%3A%20application/json%22%20%5C%0A%20%20%20%20%20-H%20%22Authorization%3A%20Bearer%20%3Cyour_user_or_api_token%3E%22%20%5C%0A%20%20%20%20%20-d%20%27%7B%22document_ids%22%3A%20%5B%22%3Cdocument_id%3E%22%5D%7D%27%0A%20%20%20%60%60%60%0A%0AMake%20sure%20the%20user%20or%20API%20token%20has%20sufficient%20permissions%20%28owner/editor/admin%29%20for%20the%20dataset.%20This%20will%20allow%20the%20/retry%20call%20to%20succeed%20%5B%5Bsource%5D%28https%3A//github.com/langgenius/dify/discussions/26691%29%5D.)&nbsp;[![Join Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share on X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/langgenius/dify/issues/31505)
Author
Owner

@hutao86 commented on GitHub (Jan 26, 2026):

I checked the indexing_status through the query table documents and found it to be completed. I also made an API call to it, but the number of recalls was still incorrect. Please provide me with a more detailed analysis

@hutao86 commented on GitHub (Jan 26, 2026): I checked the indexing_status through the query table documents and found it to be completed. I also made an API call to it, but the number of recalls was still incorrect. Please provide me with a more detailed analysis
Author
Owner

@dosubot[bot] commented on GitHub (Jan 26, 2026):

Here’s a detailed technical breakdown of why recall results can be less than your configured topk, even when indexing_status is "completed":

  1. Dify’s retrieval pipeline applies topk and score_threshold at multiple stages: initial retrieval, deduplication, reranking (if enabled), and final truncation. If any stage filters out documents (e.g., due to low scores or duplicates), you’ll get fewer than topk results—even if the index is complete and contains enough segments. This is by design and confirmed in the retrieval and rerank code paths (source, source).

  2. If score_threshold is set to 0, only documents with scores ≥ 0 are included after reranking. Any segment with a negative or missing score is filtered out, so you may see fewer than topk (source).

  3. Hybrid search and deduplication can further reduce the count. Dify deduplicates by document ID, not by segment/chunk ID, so if you have near-duplicate or overlapping segments, some may be dropped. Incomplete deduplication can also cause unpredictable recall counts (source).

  4. Metadata filtering (if enabled) or misaligned retrieval settings between the workflow and knowledge base can silently exclude segments, even if everything looks correct in the UI (source).

  5. After incremental updates (add/delete), the index may contain stale or inconsistent data until a full reindex is triggered. This can cause segments to be missing from recall, even if indexing_status is "completed". A full re-import or embedding model change forces a clean rebuild and usually restores expected recall (source).

Diagnostics you can try:

  • Double-check that both workflow and knowledge base retrieval settings (topk, score_threshold, rerank) are aligned.
  • Inspect the scores of returned segments—if some are negative or missing, that’s why they’re filtered.
  • Temporarily disable rerank or switch to vector-only search to see if recall count changes.
  • Check for duplicate or near-duplicate segments in your KB.
  • Review backend logs for retrieval or rerank errors, especially after incremental updates.
  • If you use hybrid search, try post-processing results to filter out duplicates by segment ID.

If you want to isolate the issue, try with a minimal dataset and simple retrieval config. If the problem persists, enable debug logging and check for errors during retrieval or rerank steps.

Let me know if you want help with specific log queries or further troubleshooting steps.

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other

Chat with Dosu Open in Cursor Join Discord Share on X

@dosubot[bot] commented on GitHub (Jan 26, 2026): <!-- Answer --> Here’s a detailed technical breakdown of why recall results can be less than your configured topk, even when indexing_status is "completed": 1. Dify’s retrieval pipeline applies topk and score_threshold at multiple stages: initial retrieval, deduplication, reranking (if enabled), and final truncation. If any stage filters out documents (e.g., due to low scores or duplicates), you’ll get fewer than topk results—even if the index is complete and contains enough segments. This is by design and confirmed in the retrieval and rerank code paths ([source](https://github.com/langgenius/dify/blob/8724ba04aa394edccea67383aefe035c85fe6b55/api/core/rag/retrieval/dataset_retrieval.py#L466-L1515), [source](https://github.com/langgenius/dify/blob/8724ba04aa394edccea67383aefe035c85fe6b55/api/core/rag/rerank/rerank_model.py#L15-L108)). 2. If score_threshold is set to 0, only documents with scores ≥ 0 are included after reranking. Any segment with a negative or missing score is filtered out, so you may see fewer than topk ([source](https://github.com/langgenius/dify/blob/8724ba04aa394edccea67383aefe035c85fe6b55/api/core/rag/rerank/rerank_model.py#L15-L108)). 3. Hybrid search and deduplication can further reduce the count. Dify deduplicates by document ID, not by segment/chunk ID, so if you have near-duplicate or overlapping segments, some may be dropped. Incomplete deduplication can also cause unpredictable recall counts ([source](https://github.com/langgenius/dify/issues/26277#issuecomment-3336928117)). 4. Metadata filtering (if enabled) or misaligned retrieval settings between the workflow and knowledge base can silently exclude segments, even if everything looks correct in the UI ([source](https://github.com/langgenius/dify/blob/8724ba04aa394edccea67383aefe035c85fe6b55/api/core/rag/retrieval/dataset_retrieval.py#L466-L1515)). 5. After incremental updates (add/delete), the index may contain stale or inconsistent data until a full reindex is triggered. This can cause segments to be missing from recall, even if indexing_status is "completed". A full re-import or embedding model change forces a clean rebuild and usually restores expected recall ([source](https://github.com/langgenius/dify/issues/16172#issuecomment-2736137597)). **Diagnostics you can try:** - Double-check that both workflow and knowledge base retrieval settings (topk, score_threshold, rerank) are aligned. - Inspect the scores of returned segments—if some are negative or missing, that’s why they’re filtered. - Temporarily disable rerank or switch to vector-only search to see if recall count changes. - Check for duplicate or near-duplicate segments in your KB. - Review backend logs for retrieval or rerank errors, especially after incremental updates. - If you use hybrid search, try post-processing results to filter out duplicates by segment ID. If you want to isolate the issue, try with a minimal dataset and simple retrieval config. If the problem persists, enable debug logging and check for errors during retrieval or rerank steps. Let me know if you want help with specific log queries or further troubleshooting steps. <!-- Dosu Comment Footer --> *To reply, just mention [@dosu](https://go.dosu.dev/dosubot).* --- <sup>How did I do? [Good](https://app.dosu.dev/response-feedback/a4550b39-63f7-41db-9016-d704644de39d?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/a4550b39-63f7-41db-9016-d704644de39d?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/a4550b39-63f7-41db-9016-d704644de39d?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/a4550b39-63f7-41db-9016-d704644de39d?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/a4550b39-63f7-41db-9016-d704644de39d?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/a4550b39-63f7-41db-9016-d704644de39d?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/a4550b39-63f7-41db-9016-d704644de39d?feedback_type=other)</sup> [![Chat with Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/6088a4f4-073a-43f3-b3d4-4f06fb0c05a0/ask?utm_source=github)&nbsp;[![Open in Cursor](https://dosu.dev/dosu-in-cursor.svg)](https://cursor.com/link/prompt?text=Here%E2%80%99s%20a%20detailed%20technical%20breakdown%20of%20why%20recall%20results%20can%20be%20less%20than%20your%20configured%20topk%2C%20even%20when%20indexing_status%20is%20%22completed%22%3A%0A%0A1.%20Dify%E2%80%99s%20retrieval%20pipeline%20applies%20topk%20and%20score_threshold%20at%20multiple%20stages%3A%20initial%20retrieval%2C%20deduplication%2C%20reranking%20%28if%20enabled%29%2C%20and%20final%20truncation.%20If%20any%20stage%20filters%20out%20documents%20%28e.g.%2C%20due%20to%20low%20scores%20or%20duplicates%29%2C%20you%E2%80%99ll%20get%20fewer%20than%20topk%20results%E2%80%94even%20if%20the%20index%20is%20complete%20and%20contains%20enough%20segments.%20This%20is%20by%20design%20and%20confirmed%20in%20the%20retrieval%20and%20rerank%20code%20paths%20%28%5Bsource%5D%28https%3A//github.com/langgenius/dify/blob/8724ba04aa394edccea67383aefe035c85fe6b55/api/core/rag/retrieval/dataset_retrieval.py%23L466-L1515%29%2C%20%5Bsource%5D%28https%3A//github.com/langgenius/dify/blob/8724ba04aa394edccea67383aefe035c85fe6b55/api/core/rag/rerank/rerank_model.py%23L15-L108%29%29.%0A%0A2.%20If%20score_threshold%20is%20set%20to%200%2C%20only%20documents%20with%20scores%20%E2%89%A5%200%20are%20included%20after%20reranking.%20Any%20segment%20with%20a%20negative%20or%20missing%20score%20is%20filtered%20out%2C%20so%20you%20may%20see%20fewer%20than%20topk%20%28%5Bsource%5D%28https%3A//github.com/langgenius/dify/blob/8724ba04aa394edccea67383aefe035c85fe6b55/api/core/rag/rerank/rerank_model.py%23L15-L108%29%29.%0A%0A3.%20Hybrid%20search%20and%20deduplication%20can%20further%20reduce%20the%20count.%20Dify%20deduplicates%20by%20document%20ID%2C%20not%20by%20segment/chunk%20ID%2C%20so%20if%20you%20have%20near-duplicate%20or%20overlapping%20segments%2C%20some%20may%20be%20dropped.%20Incomplete%20deduplication%20can%20also%20cause%20unpredictable%20recall%20counts%20%28%5Bsource%5D%28https%3A//github.com/langgenius/dify/issues/26277%23issuecomment-3336928117%29%29.%0A%0A4.%20Metadata%20filtering%20%28if%20enabled%29%20or%20misaligned%20retrieval%20settings%20between%20the%20workflow%20and%20knowledge%20base%20can%20silently%20exclude%20segments%2C%20even%20if%20everything%20looks%20correct%20in%20the%20UI%20%28%5Bsource%5D%28https%3A//github.com/langgenius/dify/blob/8724ba04aa394edccea67383aefe035c85fe6b55/api/core/rag/retrieval/dataset_retrieval.py%23L466-L1515%29%29.%0A%0A5.%20After%20incremental%20updates%20%28add/delete%29%2C%20the%20index%20may%20contain%20stale%20or%20inconsistent%20data%20until%20a%20full%20reindex%20is%20triggered.%20This%20can%20cause%20segments%20to%20be%20missing%20from%20recall%2C%20even%20if%20indexing_status%20is%20%22completed%22.%20A%20full%20re-import%20or%20embedding%20model%20change%20forces%20a%20clean%20rebuild%20and%20usually%20restores%20expected%20recall%20%28%5Bsource%5D%28https%3A//github.com/langgenius/dify/issues/16172%23issuecomment-2736137597%29%29.%0A%0A%2A%2ADiagnostics%20you%20can%20try%3A%2A%2A%0A-%20Double-check%20that%20both%20workflow%20and%20knowledge%20base%20retrieval%20settings%20%28topk%2C%20score_threshold%2C%20rerank%29%20are%20aligned.%0A-%20Inspect%20the%20scores%20of%20returned%20segments%E2%80%94if%20some%20are%20negative%20or%20missing%2C%20that%E2%80%99s%20why%20they%E2%80%99re%20filtered.%0A-%20Temporarily%20disable%20rerank%20or%20switch%20to%20vector-only%20search%20to%20see%20if%20recall%20count%20changes.%0A-%20Check%20for%20duplicate%20or%20near-duplicate%20segments%20in%20your%20KB.%0A-%20Review%20backend%20logs%20for%20retrieval%20or%20rerank%20errors%2C%20especially%20after%20incremental%20updates.%0A-%20If%20you%20use%20hybrid%20search%2C%20try%20post-processing%20results%20to%20filter%20out%20duplicates%20by%20segment%20ID.%0A%0AIf%20you%20want%20to%20isolate%20the%20issue%2C%20try%20with%20a%20minimal%20dataset%20and%20simple%20retrieval%20config.%20If%20the%20problem%20persists%2C%20enable%20debug%20logging%20and%20check%20for%20errors%20during%20retrieval%20or%20rerank%20steps.%20%0A%0ALet%20me%20know%20if%20you%20want%20help%20with%20specific%20log%20queries%20or%20further%20troubleshooting%20steps.)&nbsp;[![Join Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share on X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/langgenius/dify/issues/31505)
Author
Owner

@hutao86 commented on GitHub (Jan 26, 2026):

Let me repeat, the incorrect number of recalls only occurs when I delete or modify the content of a segment in the knowledge base. However, when I copy the content of the knowledge base and import it into a new knowledge base with exactly the same settings, the recalls are correct. How can you explain this

@hutao86 commented on GitHub (Jan 26, 2026): Let me repeat, the incorrect number of recalls only occurs when I delete or modify the content of a segment in the knowledge base. However, when I copy the content of the knowledge base and import it into a new knowledge base with exactly the same settings, the recalls are correct. How can you explain this
Author
Owner

@dosubot[bot] commented on GitHub (Jan 26, 2026):

This happens because incremental updates (like deleting or modifying segments) only partially clean and reload the index, which can leave behind stale or orphaned vectors in the vector store—even if the UI and database look correct. As a result, retrieval may return fewer or inconsistent results than your configured topk. When you re-import the same content into a new knowledge base, Dify triggers a full reindex: it cleans the entire index and regenerates all embeddings, which removes any inconsistencies and restores correct recall behavior. This difference in how incremental updates vs. full reindexing are handled is confirmed in the backend code and recent improvements to the indexing pipeline (reference).

A recent update also added a batch re-index operation, so you can now trigger a full reindex without needing to export and re-import the knowledge base (reference). This is the most reliable way to restore recall consistency after incremental changes.

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other

Chat with Dosu Open in Cursor Join Discord Share on X

@dosubot[bot] commented on GitHub (Jan 26, 2026): <!-- Answer --> This happens because incremental updates (like deleting or modifying segments) only partially clean and reload the index, which can leave behind stale or orphaned vectors in the vector store—even if the UI and database look correct. As a result, retrieval may return fewer or inconsistent results than your configured topk. When you re-import the same content into a new knowledge base, Dify triggers a full reindex: it cleans the entire index and regenerates all embeddings, which removes any inconsistencies and restores correct recall behavior. This difference in how incremental updates vs. full reindexing are handled is confirmed in the backend code and recent improvements to the indexing pipeline ([reference](https://github.com/langgenius/dify/blob/47d0e400ae7cb87eee8ded794e74b1e1ae6e8805/api/tasks/deal_dataset_index_update_task.py#L16-L198)). A recent update also added a batch re-index operation, so you can now trigger a full reindex without needing to export and re-import the knowledge base ([reference](https://github.com/langgenius/dify/pull/30275)). This is the most reliable way to restore recall consistency after incremental changes. <!-- Dosu Comment Footer --> *To reply, just mention [@dosu](https://go.dosu.dev/dosubot).* --- <sup>How did I do? [Good](https://app.dosu.dev/response-feedback/77bec74d-cd30-42ad-9466-ebba7ad22f3d?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/77bec74d-cd30-42ad-9466-ebba7ad22f3d?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/77bec74d-cd30-42ad-9466-ebba7ad22f3d?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/77bec74d-cd30-42ad-9466-ebba7ad22f3d?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/77bec74d-cd30-42ad-9466-ebba7ad22f3d?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/77bec74d-cd30-42ad-9466-ebba7ad22f3d?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/77bec74d-cd30-42ad-9466-ebba7ad22f3d?feedback_type=other)</sup> [![Chat with Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/6088a4f4-073a-43f3-b3d4-4f06fb0c05a0/ask?utm_source=github)&nbsp;[![Open in Cursor](https://dosu.dev/dosu-in-cursor.svg)](https://cursor.com/link/prompt?text=This%20happens%20because%20incremental%20updates%20%28like%20deleting%20or%20modifying%20segments%29%20only%20partially%20clean%20and%20reload%20the%20index%2C%20which%20can%20leave%20behind%20stale%20or%20orphaned%20vectors%20in%20the%20vector%20store%E2%80%94even%20if%20the%20UI%20and%20database%20look%20correct.%20As%20a%20result%2C%20retrieval%20may%20return%20fewer%20or%20inconsistent%20results%20than%20your%20configured%20topk.%20When%20you%20re-import%20the%20same%20content%20into%20a%20new%20knowledge%20base%2C%20Dify%20triggers%20a%20full%20reindex%3A%20it%20cleans%20the%20entire%20index%20and%20regenerates%20all%20embeddings%2C%20which%20removes%20any%20inconsistencies%20and%20restores%20correct%20recall%20behavior.%20This%20difference%20in%20how%20incremental%20updates%20vs.%20full%20reindexing%20are%20handled%20is%20confirmed%20in%20the%20backend%20code%20and%20recent%20improvements%20to%20the%20indexing%20pipeline%20%28%5Breference%5D%28https%3A//github.com/langgenius/dify/blob/47d0e400ae7cb87eee8ded794e74b1e1ae6e8805/api/tasks/deal_dataset_index_update_task.py%23L16-L198%29%29.%20%0A%0AA%20recent%20update%20also%20added%20a%20batch%20re-index%20operation%2C%20so%20you%20can%20now%20trigger%20a%20full%20reindex%20without%20needing%20to%20export%20and%20re-import%20the%20knowledge%20base%20%28%5Breference%5D%28https%3A//github.com/langgenius/dify/pull/30275%29%29.%20This%20is%20the%20most%20reliable%20way%20to%20restore%20recall%20consistency%20after%20incremental%20changes.)&nbsp;[![Join Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share on X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/langgenius/dify/issues/31505)
Author
Owner

@hutao86 commented on GitHub (Jan 26, 2026):

Please provide an interface that allows me to reindex a specific document in the knowledge base in its entirety by calling the interface, without needing to determine the current status of the document

@hutao86 commented on GitHub (Jan 26, 2026): Please provide an interface that allows me to reindex a specific document in the knowledge base in its entirety by calling the interface, without needing to determine the current status of the document
Author
Owner

@dosubot[bot] commented on GitHub (Jan 26, 2026):

You can reindex a specific document in your knowledge base by calling the API endpoint:

POST /datasets/<dataset_id>/retry
Content-Type: application/json
Authorization: Bearer <your_user_or_api_token>
{
  "document_ids": ["<document_id>"]
}

This triggers a full reindex for the specified document(s) without needing to check their current status beforehand. Make sure to use a user or API token with owner, editor, or admin permissions—dataset tokens (starting with dataset-) will not work and will return a 401 Unauthorized error details.

If a document is archived or already marked as completed, the endpoint will skip it and return an error for that document implementation. The operation is asynchronous; if you retry too quickly, you may get a "Document is being retried, please try again later" error due to a short lock window backend logic.

For bulk reindexing, you can pass multiple document IDs in the same request. This is the recommended way to restore index consistency after incremental changes recent PR.

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other

Chat with Dosu Open in Cursor Join Discord Share on X

@dosubot[bot] commented on GitHub (Jan 26, 2026): <!-- Answer --> You can reindex a specific document in your knowledge base by calling the API endpoint: ``` POST /datasets/<dataset_id>/retry Content-Type: application/json Authorization: Bearer <your_user_or_api_token> { "document_ids": ["<document_id>"] } ``` This triggers a full reindex for the specified document(s) without needing to check their current status beforehand. Make sure to use a user or API token with owner, editor, or admin permissions—dataset tokens (starting with `dataset-`) will not work and will return a 401 Unauthorized error [details](https://github.com/langgenius/dify/discussions/26691). If a document is archived or already marked as completed, the endpoint will skip it and return an error for that document [implementation](https://github.com/langgenius/dify/blob/e48419937b93ad3c273149bcac6e1d22af3bf4c8/api/controllers/console/datasets/datasets_document.py#L1134-L1174). The operation is asynchronous; if you retry too quickly, you may get a "Document is being retried, please try again later" error due to a short lock window [backend logic](https://github.com/langgenius/dify/blob/e48419937b93ad3c273149bcac6e1d22af3bf4c8/api/services/dataset_service.py#L23-L1623). For bulk reindexing, you can pass multiple document IDs in the same request. This is the recommended way to restore index consistency after incremental changes [recent PR](https://github.com/langgenius/dify/pull/30275). <!-- Dosu Comment Footer --> *To reply, just mention [@dosu](https://go.dosu.dev/dosubot).* --- <sup>How did I do? [Good](https://app.dosu.dev/response-feedback/b825d20f-6b90-4617-bf6b-1b2324aba6ae?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/b825d20f-6b90-4617-bf6b-1b2324aba6ae?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/b825d20f-6b90-4617-bf6b-1b2324aba6ae?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/b825d20f-6b90-4617-bf6b-1b2324aba6ae?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/b825d20f-6b90-4617-bf6b-1b2324aba6ae?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/b825d20f-6b90-4617-bf6b-1b2324aba6ae?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/b825d20f-6b90-4617-bf6b-1b2324aba6ae?feedback_type=other)</sup> [![Chat with Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/6088a4f4-073a-43f3-b3d4-4f06fb0c05a0/ask?utm_source=github)&nbsp;[![Open in Cursor](https://dosu.dev/dosu-in-cursor.svg)](https://cursor.com/link/prompt?text=You%20can%20reindex%20a%20specific%20document%20in%20your%20knowledge%20base%20by%20calling%20the%20API%20endpoint%3A%0A%0A%60%60%60%0APOST%20/datasets/%3Cdataset_id%3E/retry%0AContent-Type%3A%20application/json%0AAuthorization%3A%20Bearer%20%3Cyour_user_or_api_token%3E%0A%7B%0A%20%20%22document_ids%22%3A%20%5B%22%3Cdocument_id%3E%22%5D%0A%7D%0A%60%60%60%0A%0AThis%20triggers%20a%20full%20reindex%20for%20the%20specified%20document%28s%29%20without%20needing%20to%20check%20their%20current%20status%20beforehand.%20Make%20sure%20to%20use%20a%20user%20or%20API%20token%20with%20owner%2C%20editor%2C%20or%20admin%20permissions%E2%80%94dataset%20tokens%20%28starting%20with%20%60dataset-%60%29%20will%20not%20work%20and%20will%20return%20a%20401%20Unauthorized%20error%C2%A0%5Bdetails%5D%28https%3A//github.com/langgenius/dify/discussions/26691%29.%0A%0AIf%20a%20document%20is%20archived%20or%20already%20marked%20as%20completed%2C%20the%20endpoint%20will%20skip%20it%20and%20return%20an%20error%20for%20that%20document%C2%A0%5Bimplementation%5D%28https%3A//github.com/langgenius/dify/blob/e48419937b93ad3c273149bcac6e1d22af3bf4c8/api/controllers/console/datasets/datasets_document.py%23L1134-L1174%29.%20The%20operation%20is%20asynchronous%3B%20if%20you%20retry%20too%20quickly%2C%20you%20may%20get%20a%20%22Document%20is%20being%20retried%2C%20please%20try%20again%20later%22%20error%20due%20to%20a%20short%20lock%20window%C2%A0%5Bbackend%20logic%5D%28https%3A//github.com/langgenius/dify/blob/e48419937b93ad3c273149bcac6e1d22af3bf4c8/api/services/dataset_service.py%23L23-L1623%29.%0A%0AFor%20bulk%20reindexing%2C%20you%20can%20pass%20multiple%20document%20IDs%20in%20the%20same%20request.%20This%20is%20the%20recommended%20way%20to%20restore%20index%20consistency%20after%20incremental%20changes%C2%A0%5Brecent%20PR%5D%28https%3A//github.com/langgenius/dify/pull/30275%29.)&nbsp;[![Join Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share on X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/langgenius/dify/issues/31505)
Author
Owner

@hutao86 commented on GitHub (Jan 26, 2026):

您可以通过调用 API 端点来重新索引知识库中的特定文档:

POST /datasets/<dataset_id>/retry
Content-Type: application/json
Authorization: Bearer <your_user_or_api_token>
{
  "document_ids": ["<document_id>"]
}

这将触发对指定文档的完整重新索引,无需事先检查其当前状态。请确保使用具有所有者、编辑者或管理员权限的用户令牌或 API 令牌——数据集令牌(以 <dataset_token> 开头dataset-)将无法使用,并会返回 401 未授权错误 详情

如果文档已归档或标记为已完成,则该端点将跳过该文档并返回错误 。此操作是异步的;如果重试过快,可能会因为后端逻辑的锁定窗口较短而收到“文档正在重试,请稍后再试”的错误 。

对于批量重新索引,您可以在同一个请求中传递多个文档 ID。这是在最近的 PR 中提到的,用于在增量更改后恢复索引一致性的推荐方法 。

回复时只需提及@dosu即可。

我做得怎么样?|无关|错误|冗长|幻觉|举报 🐛 |其他

与 Dosu 聊天 在光标中打开 加入 Discord 分享至 X

I have already executed the above operation, but the document is in a completed state. I want to recreate it regardless of its current state, just like when I first imported the file into the knowledge base

@hutao86 commented on GitHub (Jan 26, 2026): > 您可以通过调用 API 端点来重新索引知识库中的特定文档: > > ``` > POST /datasets/<dataset_id>/retry > Content-Type: application/json > Authorization: Bearer <your_user_or_api_token> > { > "document_ids": ["<document_id>"] > } > ``` > > 这将触发对指定文档的完整重新索引,无需事先检查其当前状态。请确保使用具有所有者、编辑者或管理员权限的用户令牌或 API 令牌——数据集令牌(以 `<dataset_token>` 开头`dataset-`)将无法使用,并会返回 401 未授权错误 [详情](https://github.com/langgenius/dify/discussions/26691)。 > > [如果文档已归档或标记为已完成,则该端点将跳过该文档](https://github.com/langgenius/dify/blob/e48419937b93ad3c273149bcac6e1d22af3bf4c8/api/controllers/console/datasets/datasets_document.py#L1134-L1174)并返回错误 。此操作是异步的;如果重试过快,可能会因为[后端逻辑的](https://github.com/langgenius/dify/blob/e48419937b93ad3c273149bcac6e1d22af3bf4c8/api/services/dataset_service.py#L23-L1623)锁定窗口较短而收到“文档正在重试,请稍后再试”的错误 。 > > [对于批量重新索引,您可以在同一个请求中传递多个文档 ID。这是在最近的 PR 中](https://github.com/langgenius/dify/pull/30275)提到的,用于在增量更改后恢复索引一致性的推荐方法 。 > > _回复时只需提及[@dosu](https://go.dosu.dev/dosubot)即可。_ > > 我做得怎么样?[好](https://app.dosu.dev/response-feedback/b825d20f-6b90-4617-bf6b-1b2324aba6ae?feedback_type=great_response)|[无关](https://app.dosu.dev/response-feedback/b825d20f-6b90-4617-bf6b-1b2324aba6ae?feedback_type=irrelevant_answer)|[错误](https://app.dosu.dev/response-feedback/b825d20f-6b90-4617-bf6b-1b2324aba6ae?feedback_type=incorrect_sources)|[冗长](https://app.dosu.dev/response-feedback/b825d20f-6b90-4617-bf6b-1b2324aba6ae?feedback_type=too_verbose)|[幻觉](https://app.dosu.dev/response-feedback/b825d20f-6b90-4617-bf6b-1b2324aba6ae?feedback_type=hallucination)|[举报 🐛](https://app.dosu.dev/response-feedback/b825d20f-6b90-4617-bf6b-1b2324aba6ae?feedback_type=bug_report) |[其他](https://app.dosu.dev/response-feedback/b825d20f-6b90-4617-bf6b-1b2324aba6ae?feedback_type=other) > > [![与 Dosu 聊天](https://camo.githubusercontent.com/7c571478962a6b8a5d47cac74b6824c75e4f6731bba52377e6007f9150462923/68747470733a2f2f646f73752e6465762f646f73752d636861742d62616467652e737667)](https://app.dosu.dev/6088a4f4-073a-43f3-b3d4-4f06fb0c05a0/ask?utm_source=github) [![在光标中打开](https://camo.githubusercontent.com/bdf7dbded65ee585887f47e5fd6fa099ea0933088b4b03d02e83b4def50154d4/68747470733a2f2f646f73752e6465762f646f73752d696e2d637572736f722e737667)](https://cursor.com/link/prompt?text=You%20can%20reindex%20a%20specific%20document%20in%20your%20knowledge%20base%20by%20calling%20the%20API%20endpoint%3A%0A%0A%60%60%60%0APOST%20/datasets/%3Cdataset_id%3E/retry%0AContent-Type%3A%20application/json%0AAuthorization%3A%20Bearer%20%3Cyour_user_or_api_token%3E%0A%7B%0A%20%20%22document_ids%22%3A%20%5B%22%3Cdocument_id%3E%22%5D%0A%7D%0A%60%60%60%0A%0AThis%20triggers%20a%20full%20reindex%20for%20the%20specified%20document%28s%29%20without%20needing%20to%20check%20their%20current%20status%20beforehand.%20Make%20sure%20to%20use%20a%20user%20or%20API%20token%20with%20owner%2C%20editor%2C%20or%20admin%20permissions%E2%80%94dataset%20tokens%20%28starting%20with%20%60dataset-%60%29%20will%20not%20work%20and%20will%20return%20a%20401%20Unauthorized%20error%C2%A0%5Bdetails%5D%28https%3A//github.com/langgenius/dify/discussions/26691%29.%0A%0AIf%20a%20document%20is%20archived%20or%20already%20marked%20as%20completed%2C%20the%20endpoint%20will%20skip%20it%20and%20return%20an%20error%20for%20that%20document%C2%A0%5Bimplementation%5D%28https%3A//github.com/langgenius/dify/blob/e48419937b93ad3c273149bcac6e1d22af3bf4c8/api/controllers/console/datasets/datasets_document.py%23L1134-L1174%29.%20The%20operation%20is%20asynchronous%3B%20if%20you%20retry%20too%20quickly%2C%20you%20may%20get%20a%20%22Document%20is%20being%20retried%2C%20please%20try%20again%20later%22%20error%20due%20to%20a%20short%20lock%20window%C2%A0%5Bbackend%20logic%5D%28https%3A//github.com/langgenius/dify/blob/e48419937b93ad3c273149bcac6e1d22af3bf4c8/api/services/dataset_service.py%23L23-L1623%29.%0A%0AFor%20bulk%20reindexing%2C%20you%20can%20pass%20multiple%20document%20IDs%20in%20the%20same%20request.%20This%20is%20the%20recommended%20way%20to%20restore%20index%20consistency%20after%20incremental%20changes%C2%A0%5Brecent%20PR%5D%28https%3A//github.com/langgenius/dify/pull/30275%29.) [![加入 Discord](https://camo.githubusercontent.com/7d2066700925db1e370d956834f9ea0e5bc92cecbe84963fbd2a363e45091b4e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6a6f696e2d3538363546323f6c6f676f3d646973636f7264266c6f676f436f6c6f723d7768697465266c6162656c3d)](https://go.dosu.dev/discord-bot) [![分享至 X](https://camo.githubusercontent.com/a8bd7f3fcf3f5e3bd124eee9ae50ae2ac17b40971726665ac2121d48f9aee155/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f582d73686172652d626c61636b)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/langgenius/dify/issues/31505) I have already executed the above operation, but the document is in a completed state. I want to recreate it regardless of its current state, just like when I first imported the file into the knowledge base
Author
Owner

@dosubot[bot] commented on GitHub (Jan 26, 2026):

目前 Dify 的 /datasets/<dataset_id>/retry 接口会跳过所有已归档或 indexing_statuscompleted 的文档,并不会像新导入时那样强制重新索引。没有公开 API 或参数可以绕过这个限制,无论是 UI 还是接口,都会直接返回错误,无法实现“无视当前状态强制重建”的效果 详情

如果你确实需要实现“无论状态如何都重新索引”,只能修改后端代码:

  1. 打开 api/controllers/console/datasets/datasets_document.py,找到 /datasets/<dataset_id>/retry 的实现(DocumentRetryApi 类的 post 方法),注释或删除 if document.indexing_status == "completed": raise DocumentAlreadyFinishedError() 这一段。
  2. 确认 api/services/dataset_service.py 里的 retry_document 方法可以处理已完成状态的文档(通常只要控制器不跳过,服务层就会重置状态并触发异步重建)。
  3. 重启后端服务。

这样你就可以通过接口强制对任何文档重新索引,无论其当前状态如何。注意:这样做可能会导致重复索引、数据竞争或其他副作用,建议仅在明确需求和风险的情况下操作 参考

如果你觉得这个需求具有普遍性,可以考虑向官方提交 feature request 或 PR。

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other

Chat with Dosu Open in Cursor Join Discord Share on X

@dosubot[bot] commented on GitHub (Jan 26, 2026): <!-- Answer --> 目前 Dify 的 `/datasets/<dataset_id>/retry` 接口会跳过所有已归档或 `indexing_status` 为 `completed` 的文档,并不会像新导入时那样强制重新索引。没有公开 API 或参数可以绕过这个限制,无论是 UI 还是接口,都会直接返回错误,无法实现“无视当前状态强制重建”的效果 [详情](https://github.com/langgenius/dify/blob/e48419937b93ad3c273149bcac6e1d22af3bf4c8/api/controllers/console/datasets/datasets_document.py#L1134-L1174)。 如果你确实需要实现“无论状态如何都重新索引”,只能修改后端代码: 1. 打开 `api/controllers/console/datasets/datasets_document.py`,找到 `/datasets/<dataset_id>/retry` 的实现(`DocumentRetryApi` 类的 `post` 方法),注释或删除 `if document.indexing_status == "completed": raise DocumentAlreadyFinishedError()` 这一段。 2. 确认 `api/services/dataset_service.py` 里的 `retry_document` 方法可以处理已完成状态的文档(通常只要控制器不跳过,服务层就会重置状态并触发异步重建)。 3. 重启后端服务。 这样你就可以通过接口强制对任何文档重新索引,无论其当前状态如何。注意:这样做可能会导致重复索引、数据竞争或其他副作用,建议仅在明确需求和风险的情况下操作 [参考](https://github.com/langgenius/dify/discussions/26691)。 如果你觉得这个需求具有普遍性,可以考虑向官方提交 feature request 或 PR。 <!-- Dosu Comment Footer --> *To reply, just mention [@dosu](https://go.dosu.dev/dosubot).* --- <sup>How did I do? [Good](https://app.dosu.dev/response-feedback/a91b62ed-ef4d-45dc-b119-328bffbfcfd9?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/a91b62ed-ef4d-45dc-b119-328bffbfcfd9?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/a91b62ed-ef4d-45dc-b119-328bffbfcfd9?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/a91b62ed-ef4d-45dc-b119-328bffbfcfd9?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/a91b62ed-ef4d-45dc-b119-328bffbfcfd9?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/a91b62ed-ef4d-45dc-b119-328bffbfcfd9?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/a91b62ed-ef4d-45dc-b119-328bffbfcfd9?feedback_type=other)</sup> [![Chat with Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/6088a4f4-073a-43f3-b3d4-4f06fb0c05a0/ask?utm_source=github)&nbsp;[![Open in Cursor](https://dosu.dev/dosu-in-cursor.svg)](https://cursor.com/link/prompt?text=%E7%9B%AE%E5%89%8D%20Dify%20%E7%9A%84%20%60/datasets/%3Cdataset_id%3E/retry%60%20%E6%8E%A5%E5%8F%A3%E4%BC%9A%E8%B7%B3%E8%BF%87%E6%89%80%E6%9C%89%E5%B7%B2%E5%BD%92%E6%A1%A3%E6%88%96%20%60indexing_status%60%20%E4%B8%BA%20%60completed%60%20%E7%9A%84%E6%96%87%E6%A1%A3%EF%BC%8C%E5%B9%B6%E4%B8%8D%E4%BC%9A%E5%83%8F%E6%96%B0%E5%AF%BC%E5%85%A5%E6%97%B6%E9%82%A3%E6%A0%B7%E5%BC%BA%E5%88%B6%E9%87%8D%E6%96%B0%E7%B4%A2%E5%BC%95%E3%80%82%E6%B2%A1%E6%9C%89%E5%85%AC%E5%BC%80%20API%20%E6%88%96%E5%8F%82%E6%95%B0%E5%8F%AF%E4%BB%A5%E7%BB%95%E8%BF%87%E8%BF%99%E4%B8%AA%E9%99%90%E5%88%B6%EF%BC%8C%E6%97%A0%E8%AE%BA%E6%98%AF%20UI%20%E8%BF%98%E6%98%AF%E6%8E%A5%E5%8F%A3%EF%BC%8C%E9%83%BD%E4%BC%9A%E7%9B%B4%E6%8E%A5%E8%BF%94%E5%9B%9E%E9%94%99%E8%AF%AF%EF%BC%8C%E6%97%A0%E6%B3%95%E5%AE%9E%E7%8E%B0%E2%80%9C%E6%97%A0%E8%A7%86%E5%BD%93%E5%89%8D%E7%8A%B6%E6%80%81%E5%BC%BA%E5%88%B6%E9%87%8D%E5%BB%BA%E2%80%9D%E7%9A%84%E6%95%88%E6%9E%9C%20%5B%E8%AF%A6%E6%83%85%5D%28https%3A//github.com/langgenius/dify/blob/e48419937b93ad3c273149bcac6e1d22af3bf4c8/api/controllers/console/datasets/datasets_document.py%23L1134-L1174%29%E3%80%82%0A%0A%E5%A6%82%E6%9E%9C%E4%BD%A0%E7%A1%AE%E5%AE%9E%E9%9C%80%E8%A6%81%E5%AE%9E%E7%8E%B0%E2%80%9C%E6%97%A0%E8%AE%BA%E7%8A%B6%E6%80%81%E5%A6%82%E4%BD%95%E9%83%BD%E9%87%8D%E6%96%B0%E7%B4%A2%E5%BC%95%E2%80%9D%EF%BC%8C%E5%8F%AA%E8%83%BD%E4%BF%AE%E6%94%B9%E5%90%8E%E7%AB%AF%E4%BB%A3%E7%A0%81%EF%BC%9A%20%20%0A1.%20%E6%89%93%E5%BC%80%20%60api/controllers/console/datasets/datasets_document.py%60%EF%BC%8C%E6%89%BE%E5%88%B0%20%60/datasets/%3Cdataset_id%3E/retry%60%20%E7%9A%84%E5%AE%9E%E7%8E%B0%EF%BC%88%60DocumentRetryApi%60%20%E7%B1%BB%E7%9A%84%20%60post%60%20%E6%96%B9%E6%B3%95%EF%BC%89%EF%BC%8C%E6%B3%A8%E9%87%8A%E6%88%96%E5%88%A0%E9%99%A4%20%60if%20document.indexing_status%20%3D%3D%20%22completed%22%3A%20raise%20DocumentAlreadyFinishedError%28%29%60%20%E8%BF%99%E4%B8%80%E6%AE%B5%E3%80%82%0A2.%20%E7%A1%AE%E8%AE%A4%20%60api/services/dataset_service.py%60%20%E9%87%8C%E7%9A%84%20%60retry_document%60%20%E6%96%B9%E6%B3%95%E5%8F%AF%E4%BB%A5%E5%A4%84%E7%90%86%E5%B7%B2%E5%AE%8C%E6%88%90%E7%8A%B6%E6%80%81%E7%9A%84%E6%96%87%E6%A1%A3%EF%BC%88%E9%80%9A%E5%B8%B8%E5%8F%AA%E8%A6%81%E6%8E%A7%E5%88%B6%E5%99%A8%E4%B8%8D%E8%B7%B3%E8%BF%87%EF%BC%8C%E6%9C%8D%E5%8A%A1%E5%B1%82%E5%B0%B1%E4%BC%9A%E9%87%8D%E7%BD%AE%E7%8A%B6%E6%80%81%E5%B9%B6%E8%A7%A6%E5%8F%91%E5%BC%82%E6%AD%A5%E9%87%8D%E5%BB%BA%EF%BC%89%E3%80%82%0A3.%20%E9%87%8D%E5%90%AF%E5%90%8E%E7%AB%AF%E6%9C%8D%E5%8A%A1%E3%80%82%0A%0A%E8%BF%99%E6%A0%B7%E4%BD%A0%E5%B0%B1%E5%8F%AF%E4%BB%A5%E9%80%9A%E8%BF%87%E6%8E%A5%E5%8F%A3%E5%BC%BA%E5%88%B6%E5%AF%B9%E4%BB%BB%E4%BD%95%E6%96%87%E6%A1%A3%E9%87%8D%E6%96%B0%E7%B4%A2%E5%BC%95%EF%BC%8C%E6%97%A0%E8%AE%BA%E5%85%B6%E5%BD%93%E5%89%8D%E7%8A%B6%E6%80%81%E5%A6%82%E4%BD%95%E3%80%82%E6%B3%A8%E6%84%8F%EF%BC%9A%E8%BF%99%E6%A0%B7%E5%81%9A%E5%8F%AF%E8%83%BD%E4%BC%9A%E5%AF%BC%E8%87%B4%E9%87%8D%E5%A4%8D%E7%B4%A2%E5%BC%95%E3%80%81%E6%95%B0%E6%8D%AE%E7%AB%9E%E4%BA%89%E6%88%96%E5%85%B6%E4%BB%96%E5%89%AF%E4%BD%9C%E7%94%A8%EF%BC%8C%E5%BB%BA%E8%AE%AE%E4%BB%85%E5%9C%A8%E6%98%8E%E7%A1%AE%E9%9C%80%E6%B1%82%E5%92%8C%E9%A3%8E%E9%99%A9%E7%9A%84%E6%83%85%E5%86%B5%E4%B8%8B%E6%93%8D%E4%BD%9C%20%5B%E5%8F%82%E8%80%83%5D%28https%3A//github.com/langgenius/dify/discussions/26691%29%E3%80%82%0A%0A%E5%A6%82%E6%9E%9C%E4%BD%A0%E8%A7%89%E5%BE%97%E8%BF%99%E4%B8%AA%E9%9C%80%E6%B1%82%E5%85%B7%E6%9C%89%E6%99%AE%E9%81%8D%E6%80%A7%EF%BC%8C%E5%8F%AF%E4%BB%A5%E8%80%83%E8%99%91%E5%90%91%E5%AE%98%E6%96%B9%E6%8F%90%E4%BA%A4%20feature%20request%20%E6%88%96%20PR%E3%80%82)&nbsp;[![Join Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share on X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/langgenius/dify/issues/31505)
Author
Owner

@hutao86 commented on GitHub (Jan 26, 2026):

目前 Dify 的/datasets/<dataset_id>/retry接口会跳过所有已归档或indexing_statuscompleted的文档,并不会像新导入时那样强制重新索引。没有公开 API 或参数可以绕过这个限制,无论是 UI 还是接口,都会返回直接错误,无法实现“无视状态强制重建”的效果详情

如果你确实需要实现“无论状态如何都重新索引”,只能修改监听代码:

  1. 打开api/controllers/console/datasets/datasets_document.py,找到/datasets/<dataset_id>/retry实现(DocumentRetryApi类的post方法),注释或删除if document.indexing_status == "completed": raise DocumentAlreadyFinishedError()这一段。
  2. 确认api/services/dataset_service.py里的retry_document方法通常可以处理已完成状态的文档(只需控制器不跳过,服务层就会重置状态并触发异步重建)。
  3. 重启服务。

因此您就可以通过接口强制对任何文档重新索引,无论其当前状态如何。注意:这样做可能会导致重复索引、数据竞争或其他后果,建议仅在明确需求和风险的情况下操作参考

如果您觉得这个需求具有普遍性,可以考虑向官方提交功能请求或PR。

回复时只需提及@dosu即可。

我做得怎么样?|无关|错误|冗长|幻觉|举报 🐛 |其他

与 Dosu 聊天 在光标中打开 加入 Discord 分享至 X

I have made modifications to the installation and successfully printed the relevant logs
Retry dataset: 6525649a-0db9-4956-8f28-90c227085d28 latency: 4.796912424266338.
At the same time, I can also see on the page of the Dify knowledge base that the last update time has been updated. However, when I go to the knowledge base for recall testing, it remains the same, and it is not returning as configured

@hutao86 commented on GitHub (Jan 26, 2026): > 目前 Dify 的`/datasets/<dataset_id>/retry`接口会跳过所有已归档或`indexing_status`为`completed`的文档,并不会像新导入时那样强制重新索引。没有公开 API 或参数可以绕过这个限制,无论是 UI 还是接口,都会返回直接错误,无法实现“无视状态强制重建”的效果[详情](https://github.com/langgenius/dify/blob/e48419937b93ad3c273149bcac6e1d22af3bf4c8/api/controllers/console/datasets/datasets_document.py#L1134-L1174)。 > > 如果你确实需要实现“无论状态如何都重新索引”,只能修改监听代码: > > 1. 打开`api/controllers/console/datasets/datasets_document.py`,找到`/datasets/<dataset_id>/retry`实现(`DocumentRetryApi`类的`post`方法),注释或删除`if document.indexing_status == "completed": raise DocumentAlreadyFinishedError()`这一段。 > 2. 确认`api/services/dataset_service.py`里的`retry_document`方法通常可以处理已完成状态的文档(只需控制器不跳过,服务层就会重置状态并触发异步重建)。 > 3. 重启服务。 > > 因此您就可以通过接口强制对任何文档重新索引,无论其当前状态如何。注意:这样做可能会导致重复索引、数据竞争或其他后果,建议仅在明确需求和风险的情况下操作[参考](https://github.com/langgenius/dify/discussions/26691)。 > > 如果您觉得这个需求具有普遍性,可以考虑向官方提交功能请求或PR。 > > _回复时只需提及[@dosu](https://go.dosu.dev/dosubot)即可。_ > > 我做得怎么样?[好](https://app.dosu.dev/response-feedback/a91b62ed-ef4d-45dc-b119-328bffbfcfd9?feedback_type=great_response)|[无关](https://app.dosu.dev/response-feedback/a91b62ed-ef4d-45dc-b119-328bffbfcfd9?feedback_type=irrelevant_answer)|[错误](https://app.dosu.dev/response-feedback/a91b62ed-ef4d-45dc-b119-328bffbfcfd9?feedback_type=incorrect_sources)|[冗长](https://app.dosu.dev/response-feedback/a91b62ed-ef4d-45dc-b119-328bffbfcfd9?feedback_type=too_verbose)|[幻觉](https://app.dosu.dev/response-feedback/a91b62ed-ef4d-45dc-b119-328bffbfcfd9?feedback_type=hallucination)|[举报 🐛](https://app.dosu.dev/response-feedback/a91b62ed-ef4d-45dc-b119-328bffbfcfd9?feedback_type=bug_report) |[其他](https://app.dosu.dev/response-feedback/a91b62ed-ef4d-45dc-b119-328bffbfcfd9?feedback_type=other) > > [![与 Dosu 聊天](https://camo.githubusercontent.com/7c571478962a6b8a5d47cac74b6824c75e4f6731bba52377e6007f9150462923/68747470733a2f2f646f73752e6465762f646f73752d636861742d62616467652e737667)](https://app.dosu.dev/6088a4f4-073a-43f3-b3d4-4f06fb0c05a0/ask?utm_source=github) [![在光标中打开](https://camo.githubusercontent.com/bdf7dbded65ee585887f47e5fd6fa099ea0933088b4b03d02e83b4def50154d4/68747470733a2f2f646f73752e6465762f646f73752d696e2d637572736f722e737667)](https://cursor.com/link/prompt?text=%E7%9B%AE%E5%89%8D%20Dify%20%E7%9A%84%20%60/datasets/%3Cdataset_id%3E/retry%60%20%E6%8E%A5%E5%8F%A3%E4%BC%9A%E8%B7%B3%E8%BF%87%E6%89%80%E6%9C%89%E5%B7%B2%E5%BD%92%E6%A1%A3%E6%88%96%20%60indexing_status%60%20%E4%B8%BA%20%60completed%60%20%E7%9A%84%E6%96%87%E6%A1%A3%EF%BC%8C%E5%B9%B6%E4%B8%8D%E4%BC%9A%E5%83%8F%E6%96%B0%E5%AF%BC%E5%85%A5%E6%97%B6%E9%82%A3%E6%A0%B7%E5%BC%BA%E5%88%B6%E9%87%8D%E6%96%B0%E7%B4%A2%E5%BC%95%E3%80%82%E6%B2%A1%E6%9C%89%E5%85%AC%E5%BC%80%20API%20%E6%88%96%E5%8F%82%E6%95%B0%E5%8F%AF%E4%BB%A5%E7%BB%95%E8%BF%87%E8%BF%99%E4%B8%AA%E9%99%90%E5%88%B6%EF%BC%8C%E6%97%A0%E8%AE%BA%E6%98%AF%20UI%20%E8%BF%98%E6%98%AF%E6%8E%A5%E5%8F%A3%EF%BC%8C%E9%83%BD%E4%BC%9A%E7%9B%B4%E6%8E%A5%E8%BF%94%E5%9B%9E%E9%94%99%E8%AF%AF%EF%BC%8C%E6%97%A0%E6%B3%95%E5%AE%9E%E7%8E%B0%E2%80%9C%E6%97%A0%E8%A7%86%E5%BD%93%E5%89%8D%E7%8A%B6%E6%80%81%E5%BC%BA%E5%88%B6%E9%87%8D%E5%BB%BA%E2%80%9D%E7%9A%84%E6%95%88%E6%9E%9C%20%5B%E8%AF%A6%E6%83%85%5D%28https%3A//github.com/langgenius/dify/blob/e48419937b93ad3c273149bcac6e1d22af3bf4c8/api/controllers/console/datasets/datasets_document.py%23L1134-L1174%29%E3%80%82%0A%0A%E5%A6%82%E6%9E%9C%E4%BD%A0%E7%A1%AE%E5%AE%9E%E9%9C%80%E8%A6%81%E5%AE%9E%E7%8E%B0%E2%80%9C%E6%97%A0%E8%AE%BA%E7%8A%B6%E6%80%81%E5%A6%82%E4%BD%95%E9%83%BD%E9%87%8D%E6%96%B0%E7%B4%A2%E5%BC%95%E2%80%9D%EF%BC%8C%E5%8F%AA%E8%83%BD%E4%BF%AE%E6%94%B9%E5%90%8E%E7%AB%AF%E4%BB%A3%E7%A0%81%EF%BC%9A%20%20%0A1.%20%E6%89%93%E5%BC%80%20%60api/controllers/console/datasets/datasets_document.py%60%EF%BC%8C%E6%89%BE%E5%88%B0%20%60/datasets/%3Cdataset_id%3E/retry%60%20%E7%9A%84%E5%AE%9E%E7%8E%B0%EF%BC%88%60DocumentRetryApi%60%20%E7%B1%BB%E7%9A%84%20%60post%60%20%E6%96%B9%E6%B3%95%EF%BC%89%EF%BC%8C%E6%B3%A8%E9%87%8A%E6%88%96%E5%88%A0%E9%99%A4%20%60if%20document.indexing_status%20%3D%3D%20%22completed%22%3A%20raise%20DocumentAlreadyFinishedError%28%29%60%20%E8%BF%99%E4%B8%80%E6%AE%B5%E3%80%82%0A2.%20%E7%A1%AE%E8%AE%A4%20%60api/services/dataset_service.py%60%20%E9%87%8C%E7%9A%84%20%60retry_document%60%20%E6%96%B9%E6%B3%95%E5%8F%AF%E4%BB%A5%E5%A4%84%E7%90%86%E5%B7%B2%E5%AE%8C%E6%88%90%E7%8A%B6%E6%80%81%E7%9A%84%E6%96%87%E6%A1%A3%EF%BC%88%E9%80%9A%E5%B8%B8%E5%8F%AA%E8%A6%81%E6%8E%A7%E5%88%B6%E5%99%A8%E4%B8%8D%E8%B7%B3%E8%BF%87%EF%BC%8C%E6%9C%8D%E5%8A%A1%E5%B1%82%E5%B0%B1%E4%BC%9A%E9%87%8D%E7%BD%AE%E7%8A%B6%E6%80%81%E5%B9%B6%E8%A7%A6%E5%8F%91%E5%BC%82%E6%AD%A5%E9%87%8D%E5%BB%BA%EF%BC%89%E3%80%82%0A3.%20%E9%87%8D%E5%90%AF%E5%90%8E%E7%AB%AF%E6%9C%8D%E5%8A%A1%E3%80%82%0A%0A%E8%BF%99%E6%A0%B7%E4%BD%A0%E5%B0%B1%E5%8F%AF%E4%BB%A5%E9%80%9A%E8%BF%87%E6%8E%A5%E5%8F%A3%E5%BC%BA%E5%88%B6%E5%AF%B9%E4%BB%BB%E4%BD%95%E6%96%87%E6%A1%A3%E9%87%8D%E6%96%B0%E7%B4%A2%E5%BC%95%EF%BC%8C%E6%97%A0%E8%AE%BA%E5%85%B6%E5%BD%93%E5%89%8D%E7%8A%B6%E6%80%81%E5%A6%82%E4%BD%95%E3%80%82%E6%B3%A8%E6%84%8F%EF%BC%9A%E8%BF%99%E6%A0%B7%E5%81%9A%E5%8F%AF%E8%83%BD%E4%BC%9A%E5%AF%BC%E8%87%B4%E9%87%8D%E5%A4%8D%E7%B4%A2%E5%BC%95%E3%80%81%E6%95%B0%E6%8D%AE%E7%AB%9E%E4%BA%89%E6%88%96%E5%85%B6%E4%BB%96%E5%89%AF%E4%BD%9C%E7%94%A8%EF%BC%8C%E5%BB%BA%E8%AE%AE%E4%BB%85%E5%9C%A8%E6%98%8E%E7%A1%AE%E9%9C%80%E6%B1%82%E5%92%8C%E9%A3%8E%E9%99%A9%E7%9A%84%E6%83%85%E5%86%B5%E4%B8%8B%E6%93%8D%E4%BD%9C%20%5B%E5%8F%82%E8%80%83%5D%28https%3A//github.com/langgenius/dify/discussions/26691%29%E3%80%82%0A%0A%E5%A6%82%E6%9E%9C%E4%BD%A0%E8%A7%89%E5%BE%97%E8%BF%99%E4%B8%AA%E9%9C%80%E6%B1%82%E5%85%B7%E6%9C%89%E6%99%AE%E9%81%8D%E6%80%A7%EF%BC%8C%E5%8F%AF%E4%BB%A5%E8%80%83%E8%99%91%E5%90%91%E5%AE%98%E6%96%B9%E6%8F%90%E4%BA%A4%20feature%20request%20%E6%88%96%20PR%E3%80%82) [![加入 Discord](https://camo.githubusercontent.com/7d2066700925db1e370d956834f9ea0e5bc92cecbe84963fbd2a363e45091b4e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6a6f696e2d3538363546323f6c6f676f3d646973636f7264266c6f676f436f6c6f723d7768697465266c6162656c3d)](https://go.dosu.dev/discord-bot) [![分享至 X](https://camo.githubusercontent.com/a8bd7f3fcf3f5e3bd124eee9ae50ae2ac17b40971726665ac2121d48f9aee155/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f582d73686172652d626c61636b)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/langgenius/dify/issues/31505) I have made modifications to the installation and successfully printed the relevant logs Retry dataset: 6525649a-0db9-4956-8f28-90c227085d28 latency: 4.796912424266338. At the same time, I can also see on the page of the Dify knowledge base that the last update time has been updated. However, when I go to the knowledge base for recall testing, it remains the same, and it is not returning as configured
Author
Owner

@dosubot[bot] commented on GitHub (Jan 26, 2026):

你已经正确地修改了后端,强制触发了文档的重新索引,日志和 UI 的更新时间也都正常更新,但召回结果依然没有变化,这其实是 Dify 检索管道的正常表现:

  1. 强制重建确实会清理并重建向量和元数据,但召回数量还会受到检索流程中的 rerank(重排序)、score_threshold(分数阈值)、以及 doc_id 去重等多重影响。即使索引已重建,如果内容本身没有变化、分数依然低于阈值、或者多个 chunk 属于同一个 doc_id,被去重后,实际返回数量还是可能小于 topk(比如你设置了 10,但只返回 1、2、5 条)源码细节

  2. UI 的更新时间和日志只能说明重建任务已触发,但不能保证向量存储和检索管道已经完全同步。Dify 的检索是异步多线程的,短时间内可能有缓存或并发延迟,导致结果未及时刷新。

  3. 建议排查和测试

    • 检查 KB 和工作流的 topk、score_threshold、rerank 配置是否完全一致。
    • 临时关闭 rerank 或把 score_threshold 设为负数,测试召回数量是否变化。
    • 检查召回结果的分数,确认是否有被阈值或去重过滤掉。
    • 检查 segment/chunk 结构,确认内容和分段是否如预期。
    • 如怀疑缓存问题,可重启相关服务或清理 Redis。
    • 如果一切都没用,导出再新建知识库导入���能 100% 还原召回一致性(因为这是全量重建,彻底清理所有旧索引)。

如果需要进一步定位,可以提供具体的召回日志、segment 结构或检索配置,我可以帮你分析。
相关源码和机制说明见 这里这里

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other

Chat with Dosu Open in Cursor Join Discord Share on X

@dosubot[bot] commented on GitHub (Jan 26, 2026): <!-- Answer --> 你已经正确地修改了后端,强制触发了文档的重新索引,日志和 UI 的更新时间也都正常更新,但召回结果依然没有变化,这其实是 Dify 检索管道的正常表现: 1. **强制重建确实会清理并重建向量和元数据**,但召回数量还会受到检索流程中的 rerank(重排序)、score_threshold(分数阈值)、以及 doc_id 去重等多重影响。即使索引已重建,如果内容本身没有变化、分数依然低于阈值、或者多个 chunk 属于同一个 doc_id,被去重后,实际返回数量还是可能小于 topk(比如你设置了 10,但只返回 1、2、5 条)[源码细节](https://github.com/langgenius/dify/blob/d13638f6e49ce9a62a745971eb52ab41444dcfb9/api/core/rag/retrieval/dataset_retrieval.py#L400-L1515)。 2. **UI 的更新时间和日志只能说明重建任务已触发**,但不能保证向量存储和检索管道已经完全同步。Dify 的检索是异步多线程的,短时间内可能有缓存或并发延迟,导致结果未及时刷新。 3. **建议排查和测试**: - 检查 KB 和工作流的 topk、score_threshold、rerank 配置是否完全一致。 - 临时关闭 rerank 或把 score_threshold 设为负数,测试召回数量是否变化。 - 检查召回结果的分数,确认是否有被阈值或去重过滤掉。 - 检查 segment/chunk 结构,确认内容和分段是否如预期。 - 如怀疑缓存问题,可重启相关服务或清理 Redis。 - 如果一切都没用,导出再新建知识库导入���能 100% 还原召回一致性(因为这是全量重建,彻底清理所有旧索引)。 如果需要进一步定位,可以提供具体的召回日志、segment 结构或检索配置,我可以帮你分析。 相关源码和机制说明见 [这里](https://github.com/langgenius/dify/blob/d13638f6e49ce9a62a745971eb52ab41444dcfb9/api/core/rag/retrieval/dataset_retrieval.py#L400-L1515) 和 [这里](https://github.com/langgenius/dify/blob/d13638f6e49ce9a62a745971eb52ab41444dcfb9/api/tasks/retry_document_indexing_task.py#L21-L125)。 <!-- Dosu Comment Footer --> *To reply, just mention [@dosu](https://go.dosu.dev/dosubot).* --- <sup>How did I do? [Good](https://app.dosu.dev/response-feedback/65582927-6ccf-4164-bca4-98bdac1c57c9?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/65582927-6ccf-4164-bca4-98bdac1c57c9?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/65582927-6ccf-4164-bca4-98bdac1c57c9?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/65582927-6ccf-4164-bca4-98bdac1c57c9?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/65582927-6ccf-4164-bca4-98bdac1c57c9?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/65582927-6ccf-4164-bca4-98bdac1c57c9?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/65582927-6ccf-4164-bca4-98bdac1c57c9?feedback_type=other)</sup> [![Chat with Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/6088a4f4-073a-43f3-b3d4-4f06fb0c05a0/ask?utm_source=github)&nbsp;[![Open in Cursor](https://dosu.dev/dosu-in-cursor.svg)](https://cursor.com/link/prompt?text=%E4%BD%A0%E5%B7%B2%E7%BB%8F%E6%AD%A3%E7%A1%AE%E5%9C%B0%E4%BF%AE%E6%94%B9%E4%BA%86%E5%90%8E%E7%AB%AF%EF%BC%8C%E5%BC%BA%E5%88%B6%E8%A7%A6%E5%8F%91%E4%BA%86%E6%96%87%E6%A1%A3%E7%9A%84%E9%87%8D%E6%96%B0%E7%B4%A2%E5%BC%95%EF%BC%8C%E6%97%A5%E5%BF%97%E5%92%8C%20UI%20%E7%9A%84%E6%9B%B4%E6%96%B0%E6%97%B6%E9%97%B4%E4%B9%9F%E9%83%BD%E6%AD%A3%E5%B8%B8%E6%9B%B4%E6%96%B0%EF%BC%8C%E4%BD%86%E5%8F%AC%E5%9B%9E%E7%BB%93%E6%9E%9C%E4%BE%9D%E7%84%B6%E6%B2%A1%E6%9C%89%E5%8F%98%E5%8C%96%EF%BC%8C%E8%BF%99%E5%85%B6%E5%AE%9E%E6%98%AF%20Dify%20%E6%A3%80%E7%B4%A2%E7%AE%A1%E9%81%93%E7%9A%84%E6%AD%A3%E5%B8%B8%E8%A1%A8%E7%8E%B0%EF%BC%9A%0A%0A1.%20%2A%2A%E5%BC%BA%E5%88%B6%E9%87%8D%E5%BB%BA%E7%A1%AE%E5%AE%9E%E4%BC%9A%E6%B8%85%E7%90%86%E5%B9%B6%E9%87%8D%E5%BB%BA%E5%90%91%E9%87%8F%E5%92%8C%E5%85%83%E6%95%B0%E6%8D%AE%2A%2A%EF%BC%8C%E4%BD%86%E5%8F%AC%E5%9B%9E%E6%95%B0%E9%87%8F%E8%BF%98%E4%BC%9A%E5%8F%97%E5%88%B0%E6%A3%80%E7%B4%A2%E6%B5%81%E7%A8%8B%E4%B8%AD%E7%9A%84%20rerank%EF%BC%88%E9%87%8D%E6%8E%92%E5%BA%8F%EF%BC%89%E3%80%81score_threshold%EF%BC%88%E5%88%86%E6%95%B0%E9%98%88%E5%80%BC%EF%BC%89%E3%80%81%E4%BB%A5%E5%8F%8A%20doc_id%20%E5%8E%BB%E9%87%8D%E7%AD%89%E5%A4%9A%E9%87%8D%E5%BD%B1%E5%93%8D%E3%80%82%E5%8D%B3%E4%BD%BF%E7%B4%A2%E5%BC%95%E5%B7%B2%E9%87%8D%E5%BB%BA%EF%BC%8C%E5%A6%82%E6%9E%9C%E5%86%85%E5%AE%B9%E6%9C%AC%E8%BA%AB%E6%B2%A1%E6%9C%89%E5%8F%98%E5%8C%96%E3%80%81%E5%88%86%E6%95%B0%E4%BE%9D%E7%84%B6%E4%BD%8E%E4%BA%8E%E9%98%88%E5%80%BC%E3%80%81%E6%88%96%E8%80%85%E5%A4%9A%E4%B8%AA%20chunk%20%E5%B1%9E%E4%BA%8E%E5%90%8C%E4%B8%80%E4%B8%AA%20doc_id%EF%BC%8C%E8%A2%AB%E5%8E%BB%E9%87%8D%E5%90%8E%EF%BC%8C%E5%AE%9E%E9%99%85%E8%BF%94%E5%9B%9E%E6%95%B0%E9%87%8F%E8%BF%98%E6%98%AF%E5%8F%AF%E8%83%BD%E5%B0%8F%E4%BA%8E%20topk%EF%BC%88%E6%AF%94%E5%A6%82%E4%BD%A0%E8%AE%BE%E7%BD%AE%E4%BA%86%2010%EF%BC%8C%E4%BD%86%E5%8F%AA%E8%BF%94%E5%9B%9E%201%E3%80%812%E3%80%815%20%E6%9D%A1%EF%BC%89%5B%E6%BA%90%E7%A0%81%E7%BB%86%E8%8A%82%5D%28https%3A//github.com/langgenius/dify/blob/d13638f6e49ce9a62a745971eb52ab41444dcfb9/api/core/rag/retrieval/dataset_retrieval.py%23L400-L1515%29%E3%80%82%0A%0A2.%20%2A%2AUI%20%E7%9A%84%E6%9B%B4%E6%96%B0%E6%97%B6%E9%97%B4%E5%92%8C%E6%97%A5%E5%BF%97%E5%8F%AA%E8%83%BD%E8%AF%B4%E6%98%8E%E9%87%8D%E5%BB%BA%E4%BB%BB%E5%8A%A1%E5%B7%B2%E8%A7%A6%E5%8F%91%2A%2A%EF%BC%8C%E4%BD%86%E4%B8%8D%E8%83%BD%E4%BF%9D%E8%AF%81%E5%90%91%E9%87%8F%E5%AD%98%E5%82%A8%E5%92%8C%E6%A3%80%E7%B4%A2%E7%AE%A1%E9%81%93%E5%B7%B2%E7%BB%8F%E5%AE%8C%E5%85%A8%E5%90%8C%E6%AD%A5%E3%80%82Dify%20%E7%9A%84%E6%A3%80%E7%B4%A2%E6%98%AF%E5%BC%82%E6%AD%A5%E5%A4%9A%E7%BA%BF%E7%A8%8B%E7%9A%84%EF%BC%8C%E7%9F%AD%E6%97%B6%E9%97%B4%E5%86%85%E5%8F%AF%E8%83%BD%E6%9C%89%E7%BC%93%E5%AD%98%E6%88%96%E5%B9%B6%E5%8F%91%E5%BB%B6%E8%BF%9F%EF%BC%8C%E5%AF%BC%E8%87%B4%E7%BB%93%E6%9E%9C%E6%9C%AA%E5%8F%8A%E6%97%B6%E5%88%B7%E6%96%B0%E3%80%82%0A%0A3.%20%2A%2A%E5%BB%BA%E8%AE%AE%E6%8E%92%E6%9F%A5%E5%92%8C%E6%B5%8B%E8%AF%95%2A%2A%EF%BC%9A%0A%20%20%20-%20%E6%A3%80%E6%9F%A5%20KB%20%E5%92%8C%E5%B7%A5%E4%BD%9C%E6%B5%81%E7%9A%84%20topk%E3%80%81score_threshold%E3%80%81rerank%20%E9%85%8D%E7%BD%AE%E6%98%AF%E5%90%A6%E5%AE%8C%E5%85%A8%E4%B8%80%E8%87%B4%E3%80%82%0A%20%20%20-%20%E4%B8%B4%E6%97%B6%E5%85%B3%E9%97%AD%20rerank%20%E6%88%96%E6%8A%8A%20score_threshold%20%E8%AE%BE%E4%B8%BA%E8%B4%9F%E6%95%B0%EF%BC%8C%E6%B5%8B%E8%AF%95%E5%8F%AC%E5%9B%9E%E6%95%B0%E9%87%8F%E6%98%AF%E5%90%A6%E5%8F%98%E5%8C%96%E3%80%82%0A%20%20%20-%20%E6%A3%80%E6%9F%A5%E5%8F%AC%E5%9B%9E%E7%BB%93%E6%9E%9C%E7%9A%84%E5%88%86%E6%95%B0%EF%BC%8C%E7%A1%AE%E8%AE%A4%E6%98%AF%E5%90%A6%E6%9C%89%E8%A2%AB%E9%98%88%E5%80%BC%E6%88%96%E5%8E%BB%E9%87%8D%E8%BF%87%E6%BB%A4%E6%8E%89%E3%80%82%0A%20%20%20-%20%E6%A3%80%E6%9F%A5%20segment/chunk%20%E7%BB%93%E6%9E%84%EF%BC%8C%E7%A1%AE%E8%AE%A4%E5%86%85%E5%AE%B9%E5%92%8C%E5%88%86%E6%AE%B5%E6%98%AF%E5%90%A6%E5%A6%82%E9%A2%84%E6%9C%9F%E3%80%82%0A%20%20%20-%20%E5%A6%82%E6%80%80%E7%96%91%E7%BC%93%E5%AD%98%E9%97%AE%E9%A2%98%EF%BC%8C%E5%8F%AF%E9%87%8D%E5%90%AF%E7%9B%B8%E5%85%B3%E6%9C%8D%E5%8A%A1%E6%88%96%E6%B8%85%E7%90%86%20Redis%E3%80%82%0A%20%20%20-%20%E5%A6%82%E6%9E%9C%E4%B8%80%E5%88%87%E9%83%BD%E6%B2%A1%E7%94%A8%EF%BC%8C%E5%AF%BC%E5%87%BA%E5%86%8D%E6%96%B0%E5%BB%BA%E7%9F%A5%E8%AF%86%E5%BA%93%E5%AF%BC%E5%85%A5%EF%BC%8C%E8%83%BD%20100%25%20%E8%BF%98%E5%8E%9F%E5%8F%AC%E5%9B%9E%E4%B8%80%E8%87%B4%E6%80%A7%EF%BC%88%E5%9B%A0%E4%B8%BA%E8%BF%99%E6%98%AF%E5%85%A8%E9%87%8F%E9%87%8D%E5%BB%BA%EF%BC%8C%E5%BD%BB%E5%BA%95%E6%B8%85%E7%90%86%E6%89%80%E6%9C%89%E6%97%A7%E7%B4%A2%E5%BC%95%EF%BC%89%E3%80%82%0A%0A%E5%A6%82%E6%9E%9C%E9%9C%80%E8%A6%81%E8%BF%9B%E4%B8%80%E6%AD%A5%E5%AE%9A%E4%BD%8D%EF%BC%8C%E5%8F%AF%E4%BB%A5%E6%8F%90%E4%BE%9B%E5%85%B7%E4%BD%93%E7%9A%84%E5%8F%AC%E5%9B%9E%E6%97%A5%E5%BF%97%E3%80%81segment%20%E7%BB%93%E6%9E%84%E6%88%96%E6%A3%80%E7%B4%A2%E9%85%8D%E7%BD%AE%EF%BC%8C%E6%88%91%E5%8F%AF%E4%BB%A5%E5%B8%AE%E4%BD%A0%E5%88%86%E6%9E%90%E3%80%82%20%20%0A%E7%9B%B8%E5%85%B3%E6%BA%90%E7%A0%81%E5%92%8C%E6%9C%BA%E5%88%B6%E8%AF%B4%E6%98%8E%E8%A7%81%20%5B%E8%BF%99%E9%87%8C%5D%28https%3A//github.com/langgenius/dify/blob/d13638f6e49ce9a62a745971eb52ab41444dcfb9/api/core/rag/retrieval/dataset_retrieval.py%23L400-L1515%29%20%E5%92%8C%20%5B%E8%BF%99%E9%87%8C%5D%28https%3A//github.com/langgenius/dify/blob/d13638f6e49ce9a62a745971eb52ab41444dcfb9/api/tasks/retry_document_indexing_task.py%23L21-L125%29%E3%80%82)&nbsp;[![Join Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share on X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/langgenius/dify/issues/31505)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#21883