Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/apache/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 用于查找重复项和更新顶点属性的Gremlin查询_Python_Gremlin_Amazon Neptune_Gremlin Server_Gremlinpython - Fatal编程技术网

Python 用于查找重复项和更新顶点属性的Gremlin查询

Python 用于查找重复项和更新顶点属性的Gremlin查询,python,gremlin,amazon-neptune,gremlin-server,gremlinpython,Python,Gremlin,Amazon Neptune,Gremlin Server,Gremlinpython,我想查找重复记录并将属性isDuplicate更新为yes 我能够找到重复记录,但找不到更新属性的方法 g.V() \ .has("customerId") \ .group().by("customerId") \ .unfold() \ .toList() 上述查询还返回单个记录。我也想删除它们。这里有一种方法: gremlin> g = TinkerGraph.open().traversal() ==>graphtraversals

我想查找重复记录并将属性
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]

以下是一种方法:

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]

这是有效的。谢谢,这很有效。非常感谢。