Skip to content

armgit / dify

Public Imported from GitHub
0

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.

fix: fix missing not in (#30207)

wangxiaoleid20a8d5b7701
diff --git a/api/core/rag/retrieval/dataset_retrieval.py b/api/core/rag/retrieval/dataset_retrieval.py
index 8f6c6209252..2c3fc5ab75e 100644
--- a/api/core/rag/retrieval/dataset_retrieval.py
+++ b/api/core/rag/retrieval/dataset_retrieval.py
@@ -1219,7 +1219,7 @@ class DatasetRetrieval:
case "≥" | ">=":
filters.append(DatasetDocument.doc_metadata[metadata_name].as_float() >= value)
- case "in":
+ case "in" | "not in":
if isinstance(value, str):
value_list = [v.strip() for v in value.split(",") if v.strip()]
elif isinstance(value, (list, tuple)):
@@ -1228,9 +1228,11 @@ class DatasetRetrieval:
value_list = [str(value)] if value is not None else []
if not value_list:
- filters.append(literal(False))
+ # `field in []` is False, `field not in []` is True
+ filters.append(literal(condition == "not in"))
else:
- filters.append(json_field.in_(value_list))
+ op = json_field.in_ if condition == "in" else json_field.notin_
+ filters.append(op(value_list))
case _:
pass