Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.
Python agentagentic-aiagentic-frameworkagentic-workflowaiautomationclaudedeepseekgenaigptllmlow-codemcpnextjsno-codeopenaipythonskillsworkflow
feat: support metadata condition filter string array (#23111)
kenwoodjw28478cdc4147
diff --git a/api/core/app/app_config/entities.py b/api/core/app/app_config/entities.pyindex 75bd2f677af..0df0aa59b25 100644--- a/api/core/app/app_config/entities.py+++ b/api/core/app/app_config/entities.py@@ -148,6 +148,8 @@ SupportedComparisonOperator = Literal["is not","empty","not empty",+ "in",+ "not in",# for number"=","≠",diff --git a/api/core/rag/entities/metadata_entities.py b/api/core/rag/entities/metadata_entities.pyindex 6ef932ad22b..1f054bccdb2 100644--- a/api/core/rag/entities/metadata_entities.py+++ b/api/core/rag/entities/metadata_entities.py@@ -13,6 +13,8 @@ SupportedComparisonOperator = Literal["is not","empty","not empty",+ "in",+ "not in",# for number"=","≠",diff --git a/api/core/workflow/nodes/knowledge_retrieval/entities.py b/api/core/workflow/nodes/knowledge_retrieval/entities.pyindex f1767bdf9ef..b71271abebd 100644--- a/api/core/workflow/nodes/knowledge_retrieval/entities.py+++ b/api/core/workflow/nodes/knowledge_retrieval/entities.py@@ -74,6 +74,8 @@ SupportedComparisonOperator = Literal["is not","empty","not empty",+ "in",+ "not in",# for number"=","≠",diff --git a/api/core/workflow/nodes/knowledge_retrieval/knowledge_retrieval_node.py b/api/core/workflow/nodes/knowledge_retrieval/knowledge_retrieval_node.pyindex e041e217ca0..7303b685018 100644--- a/api/core/workflow/nodes/knowledge_retrieval/knowledge_retrieval_node.py+++ b/api/core/workflow/nodes/knowledge_retrieval/knowledge_retrieval_node.py@@ -602,6 +602,28 @@ class KnowledgeRetrievalNode(BaseNode):**{key: metadata_name, key_value: f"%{value}"}))+ case "in":+ if isinstance(value, str):+ escaped_values = [v.strip().replace("'", "''") for v in str(value).split(",")]+ escaped_value_str = ",".join(escaped_values)+ else:+ escaped_value_str = str(value)+ filters.append(+ (text(f"documents.doc_metadata ->> :{key} = any(string_to_array(:{key_value},','))")).params(+ **{key: metadata_name, key_value: escaped_value_str}+ )+ )+ case "not in":+ if isinstance(value, str):+ escaped_values = [v.strip().replace("'", "''") for v in str(value).split(",")]+ escaped_value_str = ",".join(escaped_values)+ else:+ escaped_value_str = str(value)+ filters.append(+ (text(f"documents.doc_metadata ->> :{key} != all(string_to_array(:{key_value},','))")).params(+ **{key: metadata_name, key_value: escaped_value_str}+ )+ )case "=" | "is":if isinstance(value, str):filters.append(Document.doc_metadata[metadata_name] == f'"{value}"')diff --git a/web/app/components/workflow/nodes/knowledge-retrieval/components/metadata/condition-list/utils.ts b/web/app/components/workflow/nodes/knowledge-retrieval/components/metadata/condition-list/utils.tsindex 6397023991d..10ee1aff1fc 100644--- a/web/app/components/workflow/nodes/knowledge-retrieval/components/metadata/condition-list/utils.ts+++ b/web/app/components/workflow/nodes/knowledge-retrieval/components/metadata/condition-list/utils.ts@@ -32,6 +32,8 @@ export const getOperators = (type?: MetadataFilteringVariableType) => {ComparisonOperator.endWith,ComparisonOperator.empty,ComparisonOperator.notEmpty,+ ComparisonOperator.in,+ ComparisonOperator.notIn,]case MetadataFilteringVariableType.number:return [diff --git a/web/i18n/zh-Hans/workflow.ts b/web/i18n/zh-Hans/workflow.tsindex 1f0300ae2ad..b1c28c4666c 100644--- a/web/i18n/zh-Hans/workflow.ts+++ b/web/i18n/zh-Hans/workflow.ts@@ -591,8 +591,8 @@ const translation = {'not empty': '不为空','null': '空','not null': '不为空',- 'in': '是',- 'not in': '不是',+ 'in': '在',+ 'not in': '不在','all of': '全部是','exists': '存在','not exists': '不存在',