external knowledge retrival empty because of document table is empty #6091

Closed
opened 2026-02-21 18:14:03 -05:00 by yindo · 3 comments
Owner

Originally created by @dajianguo on GitHub (Oct 14, 2024).

Self Checks

  • 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 (我已阅读并同意 Language Policy).
  • [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:)
  • Please do not modify this template :) and fill in all the required fields.

Dify version

0.9.1

Cloud or Self Hosted

Self Hosted (Source)

Steps to reproduce

I use a external knowledge,but in the chatflow, but don't retrival anything.
Because of the document table is empty when use the external data
333
set.

✔️ Expected Behavior

knowledge can retrival results

Actual Behavior

knowledge retrival empty

Originally created by @dajianguo on GitHub (Oct 14, 2024). ### Self Checks - [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 (我已阅读并同意 [Language Policy](https://github.com/langgenius/dify/issues/1542)). - [X] [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:) - [X] Please do not modify this template :) and fill in all the required fields. ### Dify version 0.9.1 ### Cloud or Self Hosted Self Hosted (Source) ### Steps to reproduce I use a external knowledge,but in the chatflow, but don't retrival anything. Because of the document table is empty when use the external data ![333](https://github.com/user-attachments/assets/ed58ea52-3212-4c03-bad1-1fd9a72bfd18) set. ### ✔️ Expected Behavior knowledge can retrival results ### ❌ Actual Behavior knowledge retrival empty
yindo added the 🐞 bug label 2026-02-21 18:14:03 -05:00
yindo closed this issue 2026-02-21 18:14:03 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Oct 14, 2024):

Hey @dajianguo! 👋 I'm here to help you with any bugs, questions, or contributions you have for Dify. Let's squash those bugs together!

The issue you're experiencing with external knowledge retrieval being empty when the document table is empty in the self-hosted Dify version 0.9.1 is due to how the _fetch_dataset_retriever method operates. This method relies on the presence of documents in the Document table to determine available datasets. It uses a subquery to count the number of available documents for each dataset, and only datasets with a non-zero document count are considered for retrieval. If the document table is empty, the subquery will not find any datasets with available documents, resulting in an empty retrieval result [1].

To resolve this, ensure that there are documents in the Document table or adjust the logic to handle cases where the document table might be empty but external datasets should still be considered.

To continue talking to Dosu, mention @dosu.

@dosubot[bot] commented on GitHub (Oct 14, 2024): <!-- Greeting --> Hey @dajianguo! 👋 I'm here to help you with any bugs, questions, or contributions you have for Dify. Let's squash those bugs together! <!-- Answer --> The issue you're experiencing with external knowledge retrieval being empty when the document table is empty in the self-hosted Dify version 0.9.1 is due to how the `_fetch_dataset_retriever` method operates. This method relies on the presence of documents in the `Document` table to determine available datasets. It uses a subquery to count the number of available documents for each dataset, and only datasets with a non-zero document count are considered for retrieval. If the document table is empty, the subquery will not find any datasets with available documents, resulting in an empty retrieval result <sup>[[1]](https://github.com/langgenius/dify/blob/main/api/core/workflow/nodes/knowledge_retrieval/knowledge_retrieval_node.py)</sup>. To resolve this, ensure that there are documents in the `Document` table or adjust the logic to handle cases where the document table might be empty but external datasets should still be considered. <!-- Dosu Comment Footer --> *To continue talking to [Dosu](https://dosu.dev), mention @dosu.*
Author
Owner

@dajianguo commented on GitHub (Oct 14, 2024):

Sorry I think it has been resovled in #9241 ; please close this question.

@dajianguo commented on GitHub (Oct 14, 2024): Sorry I think it has been resovled in #9241 ; please close this question.
Author
Owner

@sepa85 commented on GitHub (Oct 15, 2024):

Not sure if the same problem, but with cloud version 0.9.2 I also have empty result even if the knowledge test retrieves results.

Screenshot_20241015-171020.jpg

@sepa85 commented on GitHub (Oct 15, 2024): Not sure if the same problem, but with cloud version 0.9.2 I also have empty result even if the knowledge test retrieves results. ![Screenshot_20241015-171020.jpg](https://github.com/user-attachments/assets/0ba04ae7-7887-4b6f-a10e-a2fceab92522)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#6091