All guides

Original explainer

n8n Merge AI results: match IDs and inspect duplicate keys

Use Matching Fields to join input records and AI results, handling unmatched items, duplicate keys and conflicting fields.

AI Nav CityWritten / Updated Sources checked

After separate processing, AI results may be ordered differently from original records. Join two synthetic branches by id instead of relying on array position. Both branches must retain stable IDs, and you need access to Merge settings. Documented modes and an offline example were checked; no workflow or AI call was run.

Action and acceptance sequence

  1. Choose a key

    Confirm ID names and types in both branches.[1]

  2. Choose output scope

    Choose matched rows only or retain every original record.[1]

  3. Inspect duplicates and clashes

    Review one-to-many matches and same-name field ownership.[1]

Check each stage separately; the final section states execution scope.

Start with a reordered sample

Original Input 1 contains demo-a and demo-b; Input 2 returns category in the order demo-b, demo-a. Position combines by index rather than ID. This exercise requires matching the same record by ID. If the branches do not retain a common identifier, fix that upstream instead of treating coincidentally equal ordering as identity evidence.[1]

Matching Fields and output scope

Choose Combine, then Matching Fields, and specify id in Fields to Match. Keep Matches behaves like an inner join and retains matches; Enrich Input 1 behaves like a left join and retains Input 1 while adding matching data. Append outputs items from inputs sequentially rather than enriching the same ID. Choose the required behavior, then inspect a deliberately unmatched ID.[1]

Duplicate IDs and name clashes

Multiple Matches can include all matches or keep only the first. Inspect duplicate IDs before choosing, so results are not silently discarded. Input 2 wins name clashes by default; Clash Handling can change priority or add input numbers to field names. Fuzzy Compare is off by default and tolerates some type differences when enabled. A clearer input contract normalizes ID types first.[1]

Acceptance and execution scope

Check ID-to-category ownership, unmatched counts and the source of conflicting values. Stop downstream writes when duplicate keys or unexplained extra outputs appear. Offline checks covered reordered ID matching and duplicate detection. Merge, databases and workflow effects were not executed. Record your actual output mode and duplicate-match policy when adopting the guide.[1]

Article sources

Original editorial content; official descriptions and checking suggestions are distinguished.

  1. n8n · Official sources
    View details