Filter json results by list

Hey everyone, I’m stuck on an automation trying to filter the results of one node by matching a specific json field value against another array.

Describe the issue/error/question

I have 2 nodes that produce an output.
node 1 : MySQL which outputs a list of names
node 2 : Function node (originally it’s a downloaded CSV file, but I filtered emptied lines/etc) which ouputs a big list of info, one field of which is the same as the output from the MySQL node.

What I’m trying to do is :
Match and filter the info from node 2 to only keep items where the name field IS IN the list from MySQL.

I’ve tried various versions of an IF function, Merge function… but nothing has produced the desired result of keeping ALL entries. I can get an output where 1 correct entry is produced…

Thanks in advance to anyone who might be able to help :pray:

Here is the code

Hi @rgv

The merge node should be the way to go for this.
Make sure you input node 2 as the first input though. As this is the one that is being kept completely if there is a match.
If you do them the other way arround you will only get 1 result for each name I think.
Using Keep Key Matches:
image

2 Likes

Yup that was it. My problem from the first time I tried this was that instead of entering the Keep Key Matches as static text, I was entering the dynamic results {{$node…etcetc}} and so as expected, I was only getting 1 result

2 Likes

Ah Yes that can idd also be the issue. :slight_smile:
Good to see it has been solved.