Forum Discussion

kumar25's avatar
kumar25
New Contributor II
2 years ago
Solved

Find unmatched data using join

Hi,

I have 2 input streams, i used inner join and fetched the matching data, also to capture the unmatched data i used- Unmatched data to error view option.

I am able to find the get the unmatched/additional records from the left path. How can i get the similar records of the right path.

Below is the input i used. Want to get unmatched record from input-2 

 

Input-1

[
    {
        "id""1",
        "team""ABC"
    },
    {
        "id""4",
        "team""SSS"
    },
    {
        "id""5",
        "team""AAA"
    }
]
 
Input-2
[
    {
        "location""India",
        "team""ABC"
    },
    {
        "location""Canada",
        "team""SSS"
    },
     {
        "location""Germany",
        "team""MMM"
    }
]
  • kumar25 - I suggest you use Outer join type and use a Router to see which records matched based on missing key values

3 Replies

  • kumar25 - I suggest you use Outer join type and use a Router to see which records matched based on missing key values

  • alchemiz's avatar
    alchemiz
    Contributor III

    Hi kumar25 ,

    If both input streams are array you can use below script which outputs all the unmatched object in $['input-2'] 

    $['Input-2'].filter((a,b,c)=> ($['Input-1'].find((x,y,z)=> x['team'] == a['team']) || null) instanceof Null)

    Thanks,

    EmEm