Reputation: 13
In Neo4J, for a simple IN clause check, one can simply do e.g.:
itemList = [i1,i2,i3]
but how to perform an IN operation on list of lists, e.g.
I need to use the operation in conjunction with CASE WHEN, e.g.
CASE WHEN i1 IN itemLists THEN true
Upvotes: 1
Views: 269
Reputation: 30407
You can use the any()
and all()
list predicates for this, depending on what you need.
So to check if a value is in any of the lists present you can use:
any(list in itemLists WHERE i1 IN list)
Upvotes: 2
Reputation: 11216
You could just add the lists togerther if you want.
WITH 'i1' AS tester
, ['i1','i2','i3'] AS list1
, ['i4','i5','i6'] AS list2
, ['i7','i8','i9'] AS list3
RETURN CASE
WHEN tester IN (list1 + list2 + list3) THEN true
ELSE false
END AS in_list
Upvotes: 0
Reputation: 7478
Your case / when / in
solution works, but you can also try to flatten your array and then used the in
.
Example : x in reduce(s = [], list IN itemLists | s + list)
Upvotes: 1