4
votes

I have experienced that when I delete some node (which may have relationships) or relationship in neo4j using cypher query, it do not give anything in return like in mysql db.

is there any way which can give the confirmation about the number of affected node (like number of node deleted) in cypher ?

1
normally console.neo4j.org/r/x9m9nz should work, but is giving an error, I am reporting a bug.Peter Neubauer
@PeterNeubauer actually your approach seems to be correct, may be some node still connected with any relationship hence its giving error. try with MATCH n-[r?]-()agpt

1 Answers

4
votes

Below query works (I have tried this with neo4j 1.8.1 and 1.9.3 both community and enterprise version)

START root=node(1) MATCH root-[r:?]->() WHERE root.Id=12 DELETE r,root return count(root);  

We just need to make sure that node is not connected with any other relationship, if so delete those relationship prior to node as DELETE a,b,c,node where a, b and c are respective relationship connected with node.

Thanks @PeterNeubauer. :)