跳到主要内容

Filter(筛选)

按条件筛选数据项。数据项满足条件时,Filter 节点会将其传给输出端连接的下一个节点;不满足条件时,则从输出中排除该数据项。

节点参数 ​

创建筛选比较 Conditions(条件)以执行筛选。

  • 使用数据类型下拉菜单,选择条件的数据类型和比较操作类型。例如,要筛选某个日期之后的日期,请选择 Date & Time > is after(日期和时间 > 晚于)。
  • 条件中需要输入的字段和值,取决于所选的数据类型和比较方式。按数据类型列出的完整比较列表,请参阅可用的数据类型比较。

选择 Add condition(添加条件)创建更多条件。

组合条件 ​

可选择在以下情况下保留数据项:

  • 满足全部条件:创建两个或更多条件,在条件之间的下拉菜单中选择 AND(且)。
  • 满足任意条件:创建两个或更多条件,在条件之间的下拉菜单中选择 OR(或)。

无法混合使用 AND 和 OR 规则。

节点选项 ​

  • Ignore Case(忽略大小写):开启时忽略字母大小写,关闭时区分大小写。
  • Less Strict Type Validation(较宽松的类型验证):选择是否让 n8n 根据所选操作符尝试转换值类型,开启时尝试,关闭时不尝试。节点出现“wrong type:”错误时,可开启此项。

模板与示例 ​

浏览 Filter(筛选) 集成模板,或搜索所有模板

可用的数据类型比较 ​

String(字符串) ​

字符串类型支持以下比较:

  • exists(存在)
  • does not exist(不存在)
  • is empty(为空)
  • is not empty(不为空)
  • is equal to(等于)
  • is not equal to(不等于)
  • contains(包含)
  • does not contain(不包含)
  • starts with(以指定内容开头)
  • does not start with(不以指定内容开头)
  • ends with(以指定内容结尾)
  • does not end with(不以指定内容结尾)
  • matches regex(匹配正则表达式)
  • does not match regex(不匹配正则表达式)

Number(数字) ​

数字类型支持以下比较:

  • exists(存在)
  • does not exist(不存在)
  • is empty(为空)
  • is not empty(不为空)
  • is equal to(等于)
  • is not equal to(不等于)
  • is greater than(大于)
  • is less than(小于)
  • is greater than or equal to(大于或等于)
  • is less than or equal to(小于或等于)

Date & Time(日期和时间) ​

日期和时间类型支持以下比较:

  • exists(存在)
  • does not exist(不存在)
  • is empty(为空)
  • is not empty(不为空)
  • is equal to(等于)
  • is not equal to(不等于)
  • is after(晚于)
  • is before(早于)
  • is after or equal to(晚于或等于)
  • is before or equal to(早于或等于)

Boolean(布尔值) ​

布尔类型支持以下比较:

  • exists(存在)
  • does not exist(不存在)
  • is empty(为空)
  • is not empty(不为空)
  • is true(为真)
  • is false(为假)
  • is equal to(等于)
  • is not equal to(不等于)

Array(数组) ​

数组类型支持以下比较:

  • exists(存在)
  • does not exist(不存在)
  • is empty(为空)
  • is not empty(不为空)
  • contains(包含)
  • does not contain(不包含)
  • length equal to(长度等于)
  • length not equal to(长度不等于)
  • length greater than(长度大于)
  • length less than(长度小于)
  • length greater than or equal to(长度大于或等于)
  • length less than or equal to(长度小于或等于)

Object(对象) ​

对象类型支持以下比较:

  • exists(存在)
  • does not exist(不存在)
  • is empty(为空)
  • is not empty(不为空)
本文为社区中文翻译。查看对应英文原文