How to delete all relationships in neo4j graph?
18,245
Solution 1
in cypher:
deleting all relationships:
start r=relationship(*) delete r;
creating all relationships between all nodes, i'd assume:
start n=node(*),m=node(*) create unique n-[r:RELTYPE]-m;
but you rather dont want to have too many vertices, since it collapse on low memory (at least in my case i got 1mil vertices and 1gb ram)
Solution 2
In cypher3.5, start
is deprecated
.
You can use this cypher to delete all relationships
match ()-[r]->() delete r;
Related videos on Youtube
Comments
-
roman about 2 years
I need to delete all relationships between all nodes. Is there any way to delete all relationships in the neo4j graph? Note that I am using ruby bindings - the
neography
gem. There is no info about that in the wiki of the gem. I've also tried to find a way to do it in the neo4j documentation without any result.Neo4j version is 1.7.2.
-
roman over 11 yearsI've tried to do it the way you suggest but it gives the following message:
Neography::NeographyError: expected return clause.
when trying to delete all relationships. -
ulkas over 11 yearsyou are probably using some extended programming module which cause the trouble. have you tried this in pure cypher console via the admin interface? please paste the problematic part of your ruby code
-
prasanth almost 10 yearsHow to do this through Java core API??
-
ulkas almost 10 years@prasanth i dunno, i suggest to create a completely new question
-
Timothy Lombard over 4 yearsI created the movie graph on the neo4j sandbox. I wanted to delete everything. But to delete the nodes the relationships must first be deleted. This worked perfectly.
-
Dr. Strangelove about 2 yearsIn my use-case, this query is very slow, I suppose it first tries to retrieve all the relationships, then deletes them. If so, I guess a better approach would be to delete without first finding/retrieving relationships.