All relationship types EXCEPT....

Hey - I bit of a basic question but I can't seem to find an answer....

How do I return the opposite of this query? (i.e. all nodes related by any relationship type EXCEPT "PARENT_OF")

MATCH(A)-[r:PARENT_OF]-(b) RETURN *

Thanks!

That's pretty expensive if you don't bind (a) or (b) to specific nodes, but

MATCH
  (a)-[r]-(b) 
WHERE 
 type(r) <> 'PARENT_OF'
RETURN
  a, type(r), b
1 Like

Thanks Ryan - MUCH appreciated!

Its only a one off query so I can set relationship weights depending on the node attributes. so I guess I'll have to sit & wait a while :slight_smile:

Cheers @michael.knee. You might want to look at apoc.periodic.iterate for large batch operations. Speeds things up quite a bit as the size of an individual transaction gets much smaller (Neo4j APOC Procedures User Guide).

1 Like