2
votes

I am using AWS Neptune and I have to modify a certain property of a set of EDGEs with specific values. I also need this done in a single transaction. In AWS Neptune, manual transaction logic using tx.commit() and tx.rollback() is not supported. Which means I have to do this operation in a single traversal.

If I was to modify properties of vertices instead of edges, I could have got it done with a query similar to the following one:

g.V(<id 1>).property('name', 'Marko').V(<id 2>).property('name', 'Stephen');

This is because it is possible to select vertices by id in mid traversal, i.e. the GraphTraversal class has V(String ... vertexIds) as a member function.

But this is not the same for the case of edges. I am not able to select edges this way because E(String ... edgeIds) is not a member function of the GraphTraversal class.

Can somebody suggest the correct way I can solve this problem?

Thank you.

2

2 Answers

1
votes

Amazon Neptune engine 1.0.1.0.200463.0 added Support for Gremlin Sessions to enable executing multiple Gremlin traversals in a single transaction.

However, you can do it also with a single query like this:

g.E('id1', 'id2', 'id3').coalesce(
    has(id, 'id1').property('name','marko'),
    has(id, 'id2').property('name','stephan'),
    has(id, 'id3').property('name','vadas'))
1
votes

You can get the same result as a mid traversal E() using V().outE().hasId(<list of IDs>)