cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

How to find all nodes in list that are not in DB

Hello, I have a list of values and want to find out which ones are NOT in the DB already.
Have tried to put together a cypher query for an hour now but can't seem to figure it out, maybe one of you can help me figure this out.

1 ACCEPTED SOLUTION

ameyasoft
Graph Maven
Try this:
Assuming P1, P2, and P3 are your node labels,

WITH [['P1'], ['P2'], ['P3']] as nodes
MATCH (a)
WHERE labels(a) IN nodes
WITH collect(distinct labels(a)) as lbls
with apoc.coll.subtract(nodes, lbls) as notfound
return notfound


View solution in original post

1 REPLY 1

ameyasoft
Graph Maven
Try this:
Assuming P1, P2, and P3 are your node labels,

WITH [['P1'], ['P2'], ['P3']] as nodes
MATCH (a)
WHERE labels(a) IN nodes
WITH collect(distinct labels(a)) as lbls
with apoc.coll.subtract(nodes, lbls) as notfound
return notfound