dify icon indicating copy to clipboard operation
dify copied to clipboard

Search by metadata value in KB documents list

Open DavideDelbianco opened this issue 2 months ago • 4 comments

Self Checks

  • [x] I have read the Contributing Guide and Language Policy.
  • [x] I have searched for existing issues search for existing issues, including closed ones.
  • [x] I confirm that I am using English to submit this report, otherwise it will be closed.
  • [x] Please do not modify this template :) and fill in all the required fields.

1. Is this request related to a challenge you're experiencing? Tell me about your story.

I have a huge knowledge and the search functionality that relies only on the name of the doc, is not enough to find what I need.

Having the ability to search by metadata values would be much appreciated

2. Additional context or comments

No response

3. Can you help us with this feature?

  • [ ] I am interested in contributing to this feature.

DavideDelbianco avatar Oct 06 '25 08:10 DavideDelbianco

Hi! I'd like to work on this issue.

I understand you need metadata-based search/filtering in the knowledge base documents list, beyond the current name-only search. This would help manage large knowledge bases more efficiently.

My proposed approach:

Backend:

  • Extend the existing /datasets/{id}/documents API endpoint to accept metadata filter parameters
  • Reference the metadata filtering logic already implemented in Knowledge Retrieval nodes (PR #15982)
  • Add support for filtering by multiple metadata fields with AND/OR logic

Frontend:

  • Add a metadata search component to the documents list page
  • Display filter chips/tags for active metadata filters
  • Allow users to search by any custom metadata field they've created
  • Maintain existing name search functionality

Questions:

  1. Should metadata search work alongside the existing name search (combined filters)?
  2. Any preference for UI placement - separate metadata filter section or integrated into the main search bar?
  3. Should this support all metadata types (string, number, time)?

I've reviewed the existing metadata filtering implementation in the Knowledge Retrieval node and the documents list API structure. I can have an initial PR ready within 1-2 weeks.

Let me know if this approach aligns with your expectations!

adityakamat24 avatar Oct 08 '25 01:10 adityakamat24

The search text box should probably remain. The metadata filters component should probably be reusable for the hit test page too since it lacks metadata

@crazywoola can you confirm with product team if this is ok?

DavideDelbianco avatar Oct 08 '25 07:10 DavideDelbianco

@DavideDelbianco I will check it with our PM regarding this issue.

crazywoola avatar Oct 09 '25 01:10 crazywoola

@crazywoola did you have time to check? Without UI or API supporting this feature, I have a hard time figuring out which documents are missing a metadata value in a 2388 doc KB

DavideDelbianco avatar Nov 14 '25 11:11 DavideDelbianco