Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how do i delete all relationship of a specific type in Neo4j

Tags:

neo4j

cypher

I am new to Neo4j // Cypher and I am following the tutorial. Playing with the movie database i tried to delete all the "ACTED_IN" relationship using the following query

match (:Person)-[r:ACTED_IN]->(:Movie)
DELETE r;

however i found that i have i still have some "ACTED_IN" relations between nodes and i have to re-run the previous query several times to completely remove those relations.

why is it not working as i expected? what is the right way to do this?

thanks

like image 637
elabard Avatar asked Mar 11 '14 10:03

elabard


1 Answers

Just tried, it worked for me (Using Neo4j 2.0.1 and 2.1.0-M01)

match (:Person)-[:ACTED_IN]->(:Movie) return count(*);

-> count(*)
   172

match (:Person)-[r:ACTED_IN]->(:Movie) delete r;

-> Deleted 172 relationships, returned 0 rows in 172 ms

match (:Person)-[:ACTED_IN]->(:Movie) return count(*);

-> count(*)
   0
like image 123
Michael Hunger Avatar answered Nov 15 '22 08:11

Michael Hunger