简体   繁体   English

Gremlin:按两个不同顶点的多个属性分组

[英]Gremlin: Group by multiple properties from two different vertices

I have a vertex called 'Community' with property 'name', and Communities have a relationship with vertex 'People'. 我有一个名为“社区”的顶点,其属性为“名称”,而社区与顶点“人”有关系。 People have property 'id'. 人们拥有财产“身份证”。 People can belong to multiple Communities. 人们可以属于多个社区。 I want to build a gremlin query that groups all People, by 'id', that belong to each 'community'. 我想构建一个gremlin查询,以“ id”将属于每个“社区”的所有人员分组。 It can either be two columns "ID" and "Commmunity" where there would be duplicate of both, or it can be unique "Community" names with People ids separated by commas.Any ideas? 它既可以是两列“ ID”和“ Community”的重复,也可以是唯一的“ Community”名称,其People id用​​逗号分隔。有什么想法吗?

Shot in the dark here, based on the provided information: 根据提供的信息,在此处暗中拍摄:

g.V().hasLabel('Community').
  group().
    by('name').
    by(__.in('belongsTo').values('id').fold())

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM