0

I tried to delete nodes in neo4j using cypher query MATCH (n:WORKGROUP) detach delete n RETURN count(n) and getting the below error

{"results":[],"errors":[{"code":"Neo.ClientError.Statement.EntityNotFound","message":"Node with id 46103 has been deleted in this transaction"}]}.

Some times it works some time its not. So what is causing this problem?

Santosh Hegde
  • 3,420
  • 10
  • 35
  • 51

1 Answers1

1

I would not expect n to be usable after you had deleted the entire DB.

Assuming that you wanted to know what the original node count was, try this instead:

MATCH (n:WORKGROUP)
WITH n, COUNT(n) AS c
DETACH DELETE n
RETURN c;
cybersam
  • 63,203
  • 6
  • 53
  • 76
  • Then why it is working some time.? When the above query fails i used `MATCH (n:WORKGROUP)-[r]-(s) delete r,n RETURN count(n)` to delete. Some time both are failing to delete. – Santosh Hegde Sep 27 '16 at 03:45
  • The code may not always fail. Also see my answer to [this question](http://stackoverflow.com/questions/39644721/constraintviolationtransactionfailureexception-when-deleting-all-nodes-from-neo4/39645965#39645965). – cybersam Sep 27 '16 at 17:10