dify icon indicating copy to clipboard operation
dify copied to clipboard

Knowledge: Retrieval count is always 0

Open DavideDelbianco opened this issue 11 months ago • 2 comments

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 Image

DavideDelbianco avatar Feb 12 '25 07:02 DavideDelbianco

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:

  1. Retrieval Count Update Mechanism: Ensure that the _on_retrieval_end method in the DatasetRetrieval class is being triggered correctly. This method is responsible for incrementing the hit_count of the DocumentSegment when a document is retrieved [1].

  2. Logging and Debugging: Check the logs for any errors or issues during the retrieval process. The logging setup in ext_logging.py can help trace the execution flow and identify any problems with the retrieval count update [2].

  3. Configuration Settings: Verify that the top_k parameter 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].

  4. 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_count field. Check if there are any issues with the database connection or transaction [1].

  5. 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

dosubot[bot] avatar Feb 12 '25 07:02 dosubot[bot]

Can confirm this behavior.

pr-maia avatar Feb 12 '25 19:02 pr-maia