How to delete multiple nodes in neo4j
cypher, graph-databases, neo4j
Solution
You need to also delete any relationships connected to those nodes, like so:
match (n)
where n.name IS NULL
optional match (n)-[r]-()
delete n, r
Update for your second case (this deletes only orphans):
match (n)
where NOT (n)--()
and n.name IS NULL
delete n
Problem
How to delete multiple nodes, (NOT ALL) in neo4j? I have this query `MATCH (n) where n.name IS NULL delete n` It returns more than one node, I want to delete all those nodes(All nodes, which are mistakenly created thats why become null). The error, I am facing is `javax.transaction.HeuristicRollbackException: Failed to commit transaction Transaction(11, owner:"qtp16626756-84")[STATUS_NO_TRANSACTION,Resources=1], transaction rolled back ---> javax.transaction.xa.XAException` CASE 2: What to do in case of NOT NULL (property) but no any relationship is associated within a node or two; means a node which is kind of orhpan, not connected with other node. I tried to use LIMIT/SKIP but not working.Any help?