Gremlin drop() isn't working via java api

2019-09-09 17:03发布

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.

3条回答
Bombasti
2楼-- · 2019-09-09 17:34

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().

查看更多
Emotional °昔
3楼-- · 2019-09-09 17:40

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.

查看更多
做自己的国王
4楼-- · 2019-09-09 17:56

you need to commit it after traversal.

example:

graph.traversal().V().drop().iterate()
graph.tx().commit()
查看更多
登录 后发表回答