我想查找重复记录并将属性更新 isDuplicate
为yes
.
我能够找到重复的记录,找不到更新属性的方法。
g.V() \
.has("customerId") \
.group().by("customerId") \
.unfold() \
.toList()
上面的查询也返回单个记录。我也想删除它们。
我想查找重复记录并将属性更新 isDuplicate
为yes
.
我能够找到重复的记录,找不到更新属性的方法。
g.V() \
.has("customerId") \
.group().by("customerId") \
.unfold() \
.toList()
上面的查询也返回单个记录。我也想删除它们。
这是一种方法:
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]