筛选数据(Filtering data)#
在 n8n 中,筛选可以根据你想要实现的目的有不同的含义。本指南涵盖了界面中的可视化筛选以及工作流执行过程中的数据筛选。
🌐 Filtering in n8n can mean different things depending on what you want to accomplish. This guide covers both visual filtering in the UI and data filtering during workflow execution.
在用户界面中可视化筛选数据(Filter data visually in the UI)#
功能可用性
适用于社区版、云专业版和企业版计划。
在 INPUT 和 OUTPUT 面板中搜索和筛选数据。使用此功能检查节点的数据并查找特定项目。
🌐 Search and filter data in the node INPUT and OUTPUT panels. Use this to check your node's data and find specific items.
搜索:
🌐 To search:
- 在节点中,在 输入 或 输出 面板中选择 搜索
。 - 输入你的搜索词。
n8n 在你输入时进行过滤,显示包含该词的对象或行。
🌐 n8n filters as you type, displaying the objects or rows containing the term.
过滤是纯粹的可视化操作:n8n 不会更改或删除数据。关闭并重新打开节点时,过滤器会重置。
🌐 Filtering is purely visual: n8n doesn't change or delete data. The filter resets when you close and reopen the node.
在工作流执行过程中筛选数据(Filter data during workflow execution)#
要在工作流程中实际删除或过滤数据,请使用以下方法:
🌐 To actually remove or filter data in your workflow, use these approaches:
筛选项目(Filter out items)#
要根据条件从工作流中删除整个项目,请使用 Filter 节点。该节点会评估条件,并且仅传递符合你标准的项目。
🌐 To remove entire items from your workflow based on conditions, use the Filter node. This node evaluates conditions and only passes through items that meet your criteria.
筛选字段(Filter out fields)#
要在保留项目本身的同时移除项目或对象中的特定字段,请使用 编辑字段(设置)节点。将其配置为移除不需要的字段。
🌐 To remove specific fields from an item or object while keeping the item itself, use the Edit Fields (Set) node. Configure it to remove the fields you don't need.
筛选数组元素(Filter array elements)#
要在某个项目内的数组中筛选元素,可以在表达式或代码节点中使用 .filter() 方法。例如:
🌐 To filter elements within an array inside an item, use the .filter() method in an expression or Code node. For example:
1 | |
这会移除不符合条件的数组元素,同时保留项目结构。
🌐 This removes array elements that don't match your condition while preserving the item structure.
过滤掉之前执行中的重复项(Filter out duplicate items from previous executions)#
要移除在工作流先前执行中已经出现的项目,请使用 删除重复项 节点。当某个事件触发多次,但你只想处理第一次出现时,请使用此功能。
🌐 To remove items that have been seen in previous executions of a workflow, use the Remove Duplicates node. Use this when an event fires multiple times but you only want to process the first occurrence.