cancel
Showing results for 
Search instead for 
Did you mean: 

Join the community at Nodes 2022, our free virtual event on November 16 - 17.

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