When I try to add an edge that currently exists, for example:
g.addE('person-ip').from(g.V('customer:testID')).to(g.V('tel:5555555555')).property(id, 'testEdgeId').next()
I get an error like this
{"message":"Edge with id already exists: testEdgeId","Exception-Class":"java.lang.IllegalArgumentException","exceptions":["java.lang.IllegalArgumentException"],"stackTrace":"java.lang.IllegalArgumentException: Edge with id already exists: testEdgeId\n\tat org.apache.tinkerpop.gremlin.structure.Graph$Exceptions.edgeWithIdAlreadyExists(Graph.java:1141)
Is there any setting I can use when setting up gremlin server or the tinkergraph properties that would allow duplicate edges to be merged, upserted, or ignored?
There are no such settings in Gremlin Server or TinkerGraph - The pattern for upsert is as follows and is described in more detail on this StackOverflow question:
UPDATE: As of TinkerPop 3.6.0, the
fold()/coalesce()/unfold()
pattern has been largely replaced by the new steps ofmergeV()
andmergeE()
which greatly simplify the Gremlin required to do an upsert-like operation.