Return response appears in repeating number

Is case statement fine? I'm getting error. Please look at this again: (both UNWIND is now with same property)

UNWIND $var1 + $var2 as lorem
MERGE (s:Sorem) - [:LOREMED] -> (l:Lorem {
  name: lorem.name,
  mm: CASE lorem IN $var1 THEN 'ok' ELSE 'good' END
})

So, as per my first post, it should result:

{
  name: 'foo',
  mm: 'ok'
}
{
  name: 'bar',
  mm: 'ok'
}
{
  name: 'soo',
  mm: 'good'
}
{
  name: 'sar',
  mm: 'good'
}

My mistake there, you need WHEN before the condition, so CASE WHEN lorem IN $var1 ...

Ah, I also didn't notice. But still getting error. Variable var1 is not defined.

I think we need to think differently? Because $var1 will hold the array of data and using case statement will look for var1 inside the name of the property. Maybe I'm wrong?

If you're getting variable var1 is not defined, then you likely missed the $ in $var1 needed to define it as a parameter, not a variable.

As for lorem IN $var1, this is using an IN operator to check for membership of lorem in the $var1 parameter, which should be possible as this should be a list, and you combined the lists in your first line and UNWIND them to lorem.

No. I have not missed the dollar sign.

Then can you provide the entire query you're running again? And the version of Neo4j you are using? Also you are certain you're passing a $var1 list parameter?

Ah, it was my mistake. I found missing dollar sign somewhere else.

Finally worked just fine.

BTW, can we not just return variables? (Just trying to learn more...)

...
RETURN DISTINCT $var1, $var2

Goodnight.

That returns your input lists of strings. It doesn't return nodes, and it doesn't really give you any new information that you didn't have before you ran the query.

Yeah, I know that. But shouldn't it return as expected? I couldn't get the correct result. Anyways, leave it. Enough with this topic.

Hi, I forgot about my expected result and still not getting as desired result. I wanted to group them something like below which doesn't work:

UNWIND $var1 + $var2 as lorem
MERGE (s:Sorem) - [:LOREMED] -> (l:Lorem {
  name: lorem.name,
  mm: CASE lorem IN $var1 THEN 'ok' ELSE 'good' END
})
RETURN l.mm = 'ok' as okay, l.mm='good' as good

I mean to return which have 'ok', return them in array, and which have 'good' return them in separate array. Hope, this is clear.

Further, if it isn't still clear. I meant to return $var1, $var2.
RETURN $var1, $var2