Nicky Feller
Nicky Feller

Reputation: 3929

How to delete all nodes that do not have any relationships - neo4j/cypher

I am generating nodes in a neo4j database and want to remove those that have no relationships. What is the best cypher instruction to do this?

Upvotes: 5

Views: 7309

Answers (1)

Luanne
Luanne

Reputation: 19373

Try

MATCH (n)
WHERE size((n)--())=0
DELETE (n)

Upvotes: 24

Related Questions