knowledge retrieve node use metadata filter error #14380

Closed
opened 2026-02-21 19:16:59 -05:00 by yindo · 5 comments
Owner

Originally created by @winqihe on GitHub (Jun 3, 2025).

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

1.3.1

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

i use manual metadata filter in workflow ,but knowledge retrieve result is [], this filter is error,my filter is
chat(metadata) variable chat(start node parameters),why?im very hurry

✔️ Expected Behavior

knowledge retrieve result is not []

Actual Behavior

knowledge retrieve result is []

Originally created by @winqihe on GitHub (Jun 3, 2025). ### 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 1.3.1 ### Cloud or Self Hosted Self Hosted (Docker) ### Steps to reproduce i use manual metadata filter in workflow ,but knowledge retrieve result is [], this filter is error,my filter is chat(metadata) variable chat(start node parameters),why?im very hurry ### ✔️ Expected Behavior knowledge retrieve result is not [] ### ❌ Actual Behavior knowledge retrieve result is []
yindo added the 👻 feat:rag label 2026-02-21 19:16:59 -05:00
yindo closed this issue 2026-02-21 19:16:59 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Jun 3, 2025):

Your issue—manual metadata filter in the knowledge retrieval node always returning an empty result—can be caused by several factors in Dify 1.3.1.

First, ensure that the metadata keys and values you use in your filter exactly match the metadata stored in your documents. Even small mismatches or extra whitespace can cause no results to be returned. The filter logic is strict: if the filter is too restrictive, references non-existent metadata, or uses the wrong logical operator (AND/OR), you will get an empty array. Also, the metadata in your documents must be formatted as a dictionary (dict); any other format will cause errors or empty results [source].

If you are using variables (like chat(metadata) or chat(start node parameters)), make sure these variables resolve to the expected values at runtime. If the variable is empty or does not match any document metadata, the filter will not return results.

There are known issues where metadata filtering works in chat applications but not in Agent applications. If you are using an Agent workflow, be aware that metadata filtering may not function as expected due to a limitation in the Agent app implementation [source].

To troubleshoot:

  • Double-check your metadata keys/values and filter logic.
  • Test with a simple, constant value filter to confirm the mechanism works.
  • If you still get empty results, try creating a new Knowledge dataset, add documents with the correct metadata, and set up your filter again. Recreating the dataset has resolved similar issues for others [source].

If you share your exact filter configuration and a sample of your document metadata, I can help you debug further.

To reply, just mention my name @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other  Join Discord Share on X

@dosubot[bot] commented on GitHub (Jun 3, 2025): <!-- Answer --> Your issue—manual metadata filter in the knowledge retrieval node always returning an empty result—can be caused by several factors in Dify 1.3.1. First, ensure that the metadata keys and values you use in your filter exactly match the metadata stored in your documents. Even small mismatches or extra whitespace can cause no results to be returned. The filter logic is strict: if the filter is too restrictive, references non-existent metadata, or uses the wrong logical operator (AND/OR), you will get an empty array. Also, the metadata in your documents must be formatted as a dictionary (dict); any other format will cause errors or empty results [[source]](https://github.com/langgenius/dify/issues/20226). If you are using variables (like `chat(metadata)` or `chat(start node parameters)`), make sure these variables resolve to the expected values at runtime. If the variable is empty or does not match any document metadata, the filter will not return results. There are known issues where metadata filtering works in chat applications but not in Agent applications. If you are using an Agent workflow, be aware that metadata filtering may not function as expected due to a limitation in the Agent app implementation [[source]](https://github.com/langgenius/dify/issues/18676). To troubleshoot: - Double-check your metadata keys/values and filter logic. - Test with a simple, constant value filter to confirm the mechanism works. - If you still get empty results, try creating a new Knowledge dataset, add documents with the correct metadata, and set up your filter again. Recreating the dataset has resolved similar issues for others [[source]](https://github.com/langgenius/dify/issues/16177). If you share your exact filter configuration and a sample of your document metadata, I can help you debug further. <!-- Dosu Comment Footer --> *To reply, just mention my name [@dosu](https://go.dosu.dev/dosubot).* --- <sup>How did I do? [Good](https://app.dosu.dev/response-feedback/0840b0fb-7314-4241-88dc-eb0602f33bf9?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/0840b0fb-7314-4241-88dc-eb0602f33bf9?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/0840b0fb-7314-4241-88dc-eb0602f33bf9?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/0840b0fb-7314-4241-88dc-eb0602f33bf9?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/0840b0fb-7314-4241-88dc-eb0602f33bf9?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/0840b0fb-7314-4241-88dc-eb0602f33bf9?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/0840b0fb-7314-4241-88dc-eb0602f33bf9?feedback_type=other)</sup>&nbsp;&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/20578)
Author
Owner

@crazywoola commented on GitHub (Jun 3, 2025):

https://github.com/langgenius/dify/blob/0277a37fcad5ad86aeb239485c27fffd5cd90043/CONTRIBUTING.md#L22-L33

If you are in a hurry, please provide as much as you can to help investigating the issue.

@crazywoola commented on GitHub (Jun 3, 2025): https://github.com/langgenius/dify/blob/0277a37fcad5ad86aeb239485c27fffd5cd90043/CONTRIBUTING.md#L22-L33 If you are in a hurry, please provide as much as you can to help investigating the issue.
Author
Owner

@winqihe commented on GitHub (Jun 3, 2025):

Image
@winqihe commented on GitHub (Jun 3, 2025): <img width="410" alt="Image" src="https://github.com/user-attachments/assets/643344ab-ed28-4c0b-8ae1-a5b941f7189c" />
Author
Owner

@winqihe commented on GitHub (Jun 3, 2025):

Image @dosu

@winqihe commented on GitHub (Jun 3, 2025): <img width="428" alt="Image" src="https://github.com/user-attachments/assets/1966d022-88b3-47fb-87b2-19fc7b58c1d7" /> [@dosu](https://go.dosu.dev/dosubot)
Author
Owner

@winqihe commented on GitHub (Jun 3, 2025):

i Test with a simple, but its not work

@winqihe commented on GitHub (Jun 3, 2025): i Test with a simple, but its not work
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#14380