Merge by fields does compare key names as well as value?

Hi,

Just tested a merge node with “merge by fields”, and then Enrich input 2. The fields I’m entering do not have the same keyname, but have the same value.

I thought it would only compare the values, for instance “id”: “abc”, “id2” : “abc”, is a match, but my test only works if I use exactly the same keynames.

Regards,

Jos

Hi @Jos_van_Uden - sorry to hear you’re having trouble with this!

Taking a look at your example workflow (thank you so much for providing that), I don’t see why this shouldn’t work. As a heads up, this is working if you select keep matches or enrich input 1, your fields are merging probably like you’d expect, which I’d suggest you use as a workaround. But I can replicate the behaviour you’re seeing with enrich input 2.

I’m going to play around with that node a little more and flag this with our engineering team, as I don’t think that’s expected for enrich input 2 and may be a bug.

Hi,

Thanks for the quick response and for the workaround, yes, I’ll try that.

Regards,

Jos

1 Like

Hello @Jos_van_Uden @EmeraldHerald! I’m bumping this thread just in case, since I experienced something quite similar (though with version 2.1 of the node, OP uses version 2.0)

I found this same problem recently, and I think it’s because the keys are “crossed over” when you try to specifically Enrich Output 2:

For example, here, Input 1 has id as a field, while Input 2 has id2, and it doesn’t work. However, if you swap the Fields to Match over (so Input 1 has id2 and Input 2 has id), it works! You can try it on this workflow, the topmost Merge (which is configured the way you’d normally configure it) doesn’t work, while the bottom Merge (with keys swapped over) does enrich data as expected:

In other words, when in Enrich Input 1/2 mode, it works more like the first Field to Match is for the “primary data”, and the second field is for the “enrichment data”, rather than being strictly for Input 1 and Input 2. Of course, this only bites you when enriching Input 2, since when enriching Input 1 everything lines up.

I suspect the problem comes from these lines: as you can see, when enriching Input 2, the code swaps both inputs’ data over and then proceeds as if it were enriching Input 1. However, a few lines later it tries to access the Field to Match of Input 1 on Input 1’s data, and that’s where it breaks if Inputs 1 and 2 were swapped over.

Anyways. Hope it helps!

And for anyone else who may be experiencing this: if for some reason you can’t swap Inputs 1 and 2 and change the mode to Enrich Input 1, as suggested above, try to swap your Fields to Match over (put the field that appears on Input 1 on the Fields to Match textbox for Input 2, and viceversa). It seems to solve the problem for now.

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.