1

I'm using the Neography gem to interact with a Neo4j database through the REST API. I don't see any way in Neography itself (though if it's there, I'd love to use it!), nor have I been able to find by searching on Google whether this is possible directly through the REST API itself. Does anyone out there with Neo4j experience happen to know?

Dan Tao
  • 125,917
  • 54
  • 300
  • 447

2 Answers2

7

With Neography, you can send this Gremlin script:

@neo = Neography::Rest.new
@neo.execute_script("g.clear()") 

to remove all the nodes and relationships.

Josh Adell
  • 1,555
  • 8
  • 12
0

To clear all nodes and relationships except the root node, use the solution provided in neography wiki

@neo = Neography::Rest.new
@neo.execute_query("START n0=node(0),nx=node(*) MATCH n0-[r0?]-(),nx-[rx?]-() WHERE nx <> n0 DELETE r0,rx,nx")
rawonstack
  • 393
  • 4
  • 11