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.

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!

3 REPLIES 3

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

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

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 (https://neo4j-contrib.github.io/neo4j-apoc-procedures/#commit-batching).