0

Like TitanCleanup.clear(TitanGraph g) is there a way to cleanup Neo4jGraph and Neo4jHaGraph.

Amit
  • 435
  • 3
  • 13

1 Answers1

1

You can use this addon: https://github.com/jexp/neo4j-clean-remote-db-addon

If you want to do it yourself instead of calling the addon service, checkout this class:

https://github.com/jexp/neo4j-clean-remote-db-addon/blob/master/src/main/java/org/neo4j/server/extension/test/delete/Neo4jDatabaseCleaner.java

Basically you just iterate through all nodes, relations and indexes and delete them one by one.

Wouter
  • 3,976
  • 2
  • 31
  • 50
  • Or you just delete the database directory. – Michael Hunger Nov 10 '13 at 06:51
  • cleaning up the directory is not really an option when you are interacting with a HA cluster. Also how different it is to do 'start n=node(*) match n-[r:R]-() delete r, n' from iterating over all nodes and relationships and deleting them as it is done in the code you have mentioned. I have tried the former in a graph of reasonable size and ran into heap memory problems. @Michael I think it will be a useful to delegate this db clean up function to neo's execution engine some how. – Amit Nov 11 '13 at 05:16