Gremlin:通过 'name' 属性 查找顶点的重复项并作为 'id' 的列表执行
Gremlin: Find duplicates of a vertex by 'name' property and execute as list of 'id'
下面的代码按名称对所有 userProfileTemplates 进行分组,找到重复项,然后投影 userProfileTemplate 的 "name",其中名称的计数> 1。我想通过 [=25= 查找重复项],但我想将其作为 "Id" 的列表执行(Id 是 userProfileTemplate 的 属性)。有什么建议吗?
g.V().hasLabel('userProfileTemplate').group().by(values('name').fold()).unfold().filter(select(values).count(local).is(gt(1))).select(keys)unfold().project('Duplicate User Profiles')
更新:下面正在执行一个名为 "value" 的列,其中多个 'id' 对应于重复的 'name',在括号之间用逗号分隔。
g.V().hasLabel('userProfileTemplate').group().by('name').by('id').unfold().filter(select(values).count(local).is(gt(1))).select(values)
我还想执行一个显示所有重复 ID 的相应 'name' 的列。
已经差不多了,只需要再加一个by()
。
g.V().hasLabel('userProfileTemplate').
group().
by('name').
by('Id').
unfold().
filter(select(values).count(local).is(gt(1))).
select(keys)
下面的代码按名称对所有 userProfileTemplates 进行分组,找到重复项,然后投影 userProfileTemplate 的 "name",其中名称的计数> 1。我想通过 [=25= 查找重复项],但我想将其作为 "Id" 的列表执行(Id 是 userProfileTemplate 的 属性)。有什么建议吗?
g.V().hasLabel('userProfileTemplate').group().by(values('name').fold()).unfold().filter(select(values).count(local).is(gt(1))).select(keys)unfold().project('Duplicate User Profiles')
更新:下面正在执行一个名为 "value" 的列,其中多个 'id' 对应于重复的 'name',在括号之间用逗号分隔。
g.V().hasLabel('userProfileTemplate').group().by('name').by('id').unfold().filter(select(values).count(local).is(gt(1))).select(values)
我还想执行一个显示所有重复 ID 的相应 'name' 的列。
已经差不多了,只需要再加一个by()
。
g.V().hasLabel('userProfileTemplate').
group().
by('name').
by('Id').
unfold().
filter(select(values).count(local).is(gt(1))).
select(keys)