【问题标题】:Gremlin query for find duplicates and update vertex propertyGremlin 查询查找重复项和更新顶点属性
【发布时间】:2020-12-09 08:51:00
【问题描述】:

我想查找重复记录并更新属性 isDuplicateyes

我能够找到重复记录,但找不到更新属性的方法。

 g.V() \
.has("customerId") \
.group().by("customerId") \
.unfold() \
.toList()

上述查询也返回单个记录。我也想删除它们。

【问题讨论】:

    标签: python gremlin amazon-neptune gremlin-server gremlinpython


    【解决方案1】:

    这是一种方法:

    gremlin> g = TinkerGraph.open().traversal()
    ==>graphtraversalsource[tinkergraph[vertices:0 edges:0], standard]
    gremlin> g.addV('person').property('customerId','alice').
    ......1>   addV('person').property('customerId','alice').
    ......2>   addV('person').property('customerId','bob').
    ......3>   addV('person').property('customerId','alice').iterate()
    gremlin> g.V().hasLabel('person').has('customerId').
    ......1>   group().by('customerId').
    ......2>   unfold().
    ......3>   select(values).filter(count(local).is(gt(1))).unfold().
    ......4>   property('isDuplicate','yes')
    ==>v[0]
    ==>v[2]
    ==>v[6]
    gremlin> g.V().elementMap()
    ==>[id:0,label:person,customerId:alice,isDuplicate:yes]
    ==>[id:2,label:person,customerId:alice,isDuplicate:yes]
    ==>[id:4,label:person,customerId:bob]
    ==>[id:6,label:person,customerId:alice,isDuplicate:yes]
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-01-15
      • 1970-01-01
      • 2019-09-15
      • 1970-01-01
      • 2021-05-29
      • 1970-01-01
      • 1970-01-01
      • 2019-06-02
      相关资源
      最近更新 更多