Gremlin drop() isn't working via java api

2019-09-09 17:40发布

问题:

I'm using titan db 1.0.0 backed by a local dynamodb instance (which uses the 3.0 tinkerpop stack). I've spent more time than I'd like to admit trying to figure out why drop() wasn't working. In my use case I'm trying to remove a specific edge found via a traversal, but even graph.traversal().V().drop() wasn't working. I did much googling, but perhaps not with the right keywords. I finally figured out the issue which I'll specify in my answer. Hopefully others find this useful.

回答1:

I finally remembered reading somewhere (unfortunately I can't find it now to share the link edit:see the link provided by Stephen Mallete), that when dealing with gremlin in java-land, you needed to explicitly iterate the traversal.

So the trick was graph.traversal().V().drop().iterate(). Note this is not needed when using the gremlin console (at least with 3.0). You can just use graph.traversal().V().drop().



回答2:

You could try the following to clear your graph:

TitanGraph titanGraph = TitanFactory.open(config);
TitanCleanup.clear(graph);

This essentially drops the keyspace in Cassandra and clears the graph completely including indexing.



回答3:

you need to commit it after traversal.

example:

graph.traversal().V().drop().iterate()
graph.tx().commit()