1

We are trying to update neo4j database with our own graphhml file. For that we need to clear the neo4j database. When we try using g.clear() it gives an error. The trace is as follows :

gremlin> g.clear() No signature of method: groovy.lang.MissingMethodException.clear() is applicable for argument types: () values: [] Possible solutions: sleep(long), sleep(long, groovy.lang.Closure), every(), grep(), collect(), use([Ljava.lang.Object;)

What could be the problem ?

2 Answers2

1

Graph.clear() was removed when Blueprints went to version 2.0.0.

Try using remove():

gremlin> g = new Neo4jGraph("/tmp/neo4j")
==>neo4jgraph[EmbeddedGraphDatabase [\tmp\neo4j]]
gremlin> g.addVertex()
==>v[1]
gremlin> g.commit()
==>null
gremlin> g.V
==>v[1]
gremlin> g.V.remove()
==>null
gremlin> g.V
==>v[1]
gremlin> g.commit()
==>null
gremlin> g.V
gremlin>
stephen mallette
  • 45,298
  • 5
  • 67
  • 135
1

Graph.clear() is either removed or sometimes disabled even though it should be available, another method apart from stephen's answer is:

g.V.sideEffect{g.removeVertex(it)}.iterate();

a commit is necessary if you are not submitting your commands via REST

or see: Gremlin remove all Vertex

Community
  • 1
  • 1
PerfectPixel
  • 1,918
  • 1
  • 17
  • 18