比较数据集(Compare Datasets)#
比较数据集节点可帮助你比较来自两个输入流的数据。
🌐 The Compare Datasets node helps you compare data from two input streams.
节点参数(Node parameters)#
- 决定要比较哪些字段。在 输入 A 字段 中,输入要从输入流 A 使用的字段名称。在 输入 B 字段 中,输入要从输入流 B 使用的字段名称。
- 可选:你可以按多个字段进行比较。选择 添加匹配字段 来设置更多比较。
- 选择如何处理数据集之间的差异。在 存在差异时,请选择以下选项之一:
- 使用输入 A 版本 将输入流 A 视为真实来源。
- 使用输入 B 版本 将输入流 B 视为真实来源。
- 使用多种版本 来为不同的字段使用不同的输入。
- 使用 Prefer 来选择 Input A 版本 或 Input B 版本 作为主要的权威来源。
- 输入作为“除了全部之外”例外的输入字段,以从其他输入源获取数据。要添加多个输入字段,请输入以逗号分隔的列表。
- 包括两个版本 以在输出中包含两个输入流,这可能会使结构更复杂。
- 决定是否使用模糊比较。开启后,在比较字段时会容忍微小的类型差异。例如,当开启模糊比较时,数字3和字符串
3会被视为相同,但关闭时则不会被视为相同。
理解项目比较(Understand item comparison)#
项目比较是一个两阶段过程:
🌐 Item comparison is a two stage process:
- n8n 检查你选择进行比较的字段值在两个输入中是否匹配。
- 如果要比较的字段匹配,n8n 将比较项中的所有字段,以确定项是否相同。
节点选项(Node options)#
使用节点 选项 来优化你的比较或调整比较行为。
🌐 Use the node Options to refine your comparison or tweak comparison behavior.
要跳过比较的字段(Fields to Skip Comparing)#
输入要在比较中忽略的字段名称。
🌐 Enter field names that you want to ignore in the comparison.
例如,如果你使用 person.language 作为 匹配字段 来比较下面的两个数据集,n8n 会将它们返回为不同。如果你将 person.name 添加到 跳过比较的字段,n8n 会将它们返回为匹配。
🌐 For example, if you compare the two datasets below using person.language as the Fields to Match, n8n returns them as different. If you add person.name to Fields to Skip Comparing, n8n returns them as matching.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | |
禁用点号表示法(Disable Dot Notation)#
是否禁止在字段名称中使用 parent.child 引用子字段(开启表示禁止,关闭表示允许,默认)。
🌐 Whether to disallow referencing child fields using parent.child in the field name (turned on) or allow it (turned off, default).
多个匹配项(Multiple Matches)#
选择如何处理重复数据。默认选项是包含所有匹配项。你可以选择仅包含第一个匹配项。
🌐 Choose how to handle duplicate data. The default is Include All Matches. You can choose Include First Match Only.
例如,给定以下两个数据集:
🌐 For example, given these two datasets:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | |
n8n 在 Same Branch 标签页中返回三个项目。两个分支中的数据是相同的。
🌐 n8n returns three items in the Same Branch tab. The data is the same in both branches.
如果你选择 仅包含首次匹配,n8n 会在 同一分支 标签中返回两个项目。两个分支中的数据相同,但 n8n 只返回匹配 “apple” 项目的第一个出现。
🌐 If you select Include First Match Only, n8n returns two items, in the Same Branch tab. The data is the same in both branches, but n8n only returns the first occurrence of the matching "apple" items.
理解输出(Understand the output)#
有四种输出选项:
🌐 There are four output options:
- 仅在 A 分支中:包含仅出现在第一个输入中的数据。
- 相同分支:包含在两个输入中都相同的数据。
- 不同分支:包含输入之间不同的数据。
- 仅在 B 分支:包含只出现在第二个输出中的数据。