Knowledge: Retrieval count is always 0
Self Checks
- [x] This is only for bug report, if you would like to ask a question, please head to Discussions.
- [x] I have searched for existing issues search for existing issues, including closed ones.
- [x] I confirm that I am using English to submit this report (我已阅读并同意 Language Policy).
- [x] [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:)
- [x] Please do not modify this template :) and fill in all the required fields.
Dify version
0.15.3
Cloud or Self Hosted
Self Hosted (Docker)
Steps to reproduce
-
Using the API:
- Create knowledge base
- Upload a document by text with mode parent-child (full-doc)
-
Attach the knowledge to a chat-flow application
-
Ask the chatbot a question that loads the desired document
✔️ Expected Behavior
In the knowledge administrative UI, the documents should show the count of times they were retrieved
❌ Actual Behavior
Every document shows 0 in retrieval count
The issue of the retrieval count always showing 0 could be related to several factors in the Dify codebase. Here are some potential areas to investigate:
-
Retrieval Count Update Mechanism: Ensure that the
_on_retrieval_endmethod in theDatasetRetrievalclass is being triggered correctly. This method is responsible for incrementing thehit_countof theDocumentSegmentwhen a document is retrieved [1]. -
Logging and Debugging: Check the logs for any errors or issues during the retrieval process. The logging setup in
ext_logging.pycan help trace the execution flow and identify any problems with the retrieval count update [2]. -
Configuration Settings: Verify that the
top_kparameter in the retrieval model configuration is set correctly. This parameter determines the number of documents to retrieve and could affect the retrieval process if not configured properly [1]. -
Database Updates: Ensure that the database updates are being committed successfully. The retrieval count is updated in the database using a query that increments the
hit_countfield. Check if there are any issues with the database connection or transaction [1]. -
Error Handling: Although specific error handling for the retrieval count update process wasn't found, ensure that any exceptions during the update process are logged and handled appropriately.
By examining these areas, you may be able to identify the root cause of the issue and resolve the problem with the retrieval count not updating.
To continue talking to Dosu, mention @dosu.
Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Other | Bug Report
Can confirm this behavior.