1

当我尝试添加当前存在的边缘时,例如:

g.addE('person-ip').from(g.V('customer:testID')).to(g.V('tel:5555555555')).property(id, 'testEdgeId').next()

我收到这样的错误

{"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)

在设置 gremlin 服务器或 tinkergraph 属性时,我是否可以使用任何设置来允许合并、更新或忽略重复的边?

4

1 回答 1

4

Gremlin Server 或 TinkerGraph 中没有此类设置 - upsert 的模式如下:

g.E('testEdgeId').
  fold().
  coalesce(unfold(),
           V('customer:testID').as('start').
           V('tel:5555555555').
           addE('person-ip').
             from('start')
           property(id,'testEdgeId'))
于 2018-08-04T09:57:54.590 回答