简体   繁体   中英

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'. 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?

Shot in the dark here, based on the provided information:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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