I need to replace the vertex
T.id
, unfortunately, it's not allowed in Apache Tinkerpop Gremlin
. So I need to delete the vertex and create a new one with the same properties
and incoming & outgoing edges
.
Is there any easy way/shortcut to re-create?
One approach is to make a clone of the vertex you are going to delete first. This can be done in Gremlin.
Here is one way to clone the DFW vertex in the air routes data set. You can amend this code to also add your new ID value.
g.V().has('code','DFW').as('dfw').
addV().property(label, select('dfw').label()).as('new').
select('dfw').properties().as('dfwprops').
select('new').property(select('dfwprops').key(),
select('dfwprops').value())
There is an example and discussion here http://www.kelvinlawrence.net/book/PracticalGremlin.html#dfwcopy
UPDATED
Adding a link to the recipe for moving edges.
https://tinkerpop.apache.org/docs/current/recipes/#edge-move