langgenius / langgenius/dify

Support variable assignment in the metadata filtering feature of the knowledge retrieval node within Dify workflows.

Open
#38,497 1 comment 1 reaction 0 assignees View on GitHub
project#dify
Dominant language
TypeScript
Stars
156k
Forks
24.6k
Avg merge
22h 9m
Merged PRs (30d)
610

Description

### Self Checks

- [x] I have read the [Contributing Guide](https://github.com/langgenius/dify/blob/main/CONTRIBUTING.md) and [Language Policy](https://github.com/langgenius/dify/issues/1542).
- [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, 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.

Purpose:
I have built a workflow to detect whether newly discovered knowledge already has a similar version in the knowledge base.

Process:
In the initial version, I did not consider comparing knowledge across multiple users. However, once multiple users are involved, without isolation, User A's similarity detection would compare against all users' knowledge bases. To address this, I used metadata filtering to restrict retrieval to each user's own knowledge base.

Problem:
I found that metadata filtering only supports hard‑coded values (static constants). This makes the filtering a superficial fix—I still have to write many identical branches that differ only in the metadata label, and each user requires a separate branch. This is extremely cumbersome and does not scale.

Requested improvement:
I would like the metadata filtering condition in the knowledge retrieval node to support variable assignment, so that I can dynamically pass the user ID (or knowledge base identifier) from workflow variables, avoiding the need for redundant branches.

### 2. Additional context or comments

As shown in the figure, only static values can be assigned here. I hope to add support for using "/" as a variable reference (e.g., /variable_name) to dynamically assign values in this field.
Image

### 3. Can you help us with this feature?

- [x] I am interested in contributing to this feature.

Contributor guide

Open the contributing guide

Research direction

The issue names no files or tests. Start by locating the knowledge retrieval node's metadata-filtering field and the workflow's existing variable-reference handling; trace how static filter values are passed, then verify that a /variable_name value resolves to a workflow variable and scopes retrieval to that value.

Written by the indexing model from the issue text.

Assessment

Domain
ai
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.