5
votes

I am using neo4j MATCH and get two list of User: listA,listB, and listB is part of listA
how can I return users only in listA but not in listB use cipher query
the cipher like :

MATCH listA, listB
RETURN listA - listB

Here is my previous question: neo4j cypher multi relationship between nodes

Done See solution in the link above

2
The answer you link to may have solved your problem but I don't see how it answers this questionjjaderberg

2 Answers

8
votes

To return members of one list that are not in another you can use the FILTER function (docs), for example

WITH [1,2,3,4,5,6] as listA, [1,2,3] as listB
RETURN FILTER( n IN listA WHERE NOT n IN listB ) as listC

c
4, 5, 6
Returned 1 row in 90 ms
2
votes

Filter function is removed in the latest Neo4j version 4.0 doc here instead, use List comprehension

WITH [1,2,3,4,5,6] as listA, [1,2,3] as listB
RETURN [n IN listA WHERE NOT n IN listB] as listC

This results in an output 4, 5, 6