1
votes

I think it is a simple question but I am not able to find the answer. I have tried various ways to delete a relationship in neo4j 1.6 using cypher, but getting error.

start n = node(1) match n-[r:KNOWS]-m delete r; 

I want to delete all relationships of type KNOWS , but I am getting the error -

==> SyntaxException: expected return clause
==> "start n = node(1) match n-[r:KNOWS]-m delete r;  "

Even if I give

start n = node(1) match n-[r:KNOWS]-m delete r return count(r); 

it doesnt work.

Note : Above issue is not seen on neo4j 1.8, but I have to somehow run the query on neo4j 1.6.

2
you can use your neo4j-shell with traverse and rmrel commands or the javascript eval. You should be also able to run a 1.8 shell against 1.6 as the store-format hasn't changed. But be sure to make a backup before!!Michael Hunger
thanks Michael for the reply, I am your fan! eval is good for small changes in nodes but for a huge number of nodes(million) it takes hours to do so and somehow not reliable (eg. getRelationships() works on one system and not on another system with same version of neo4j).hack3r

2 Answers

2
votes

You won't be able to do this via Cypher at least using 1.6

Mutating Cypher is available from 1.8. You might have to use the API to delete.

0
votes

After spending some time on the best way to do this for a large number of nodes, moving the data folder from a neo4j 1.6 instance to neo4j 1.8 instance and running cypher queries there is the fastest way and outperforms running javascript on neo4j-shell / calling the REST api.