2

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?

piet.t
  • 11,718
  • 21
  • 43
  • 52
Veronica
  • 145
  • 12
  • Could you please provide a Gremlin script that creates some sample data - here is an example https://stackoverflow.com/questions/51388315/gremlin-choose-one-item-at-random – stephen mallette Aug 02 '19 at 15:47
  • I don't have this info.. anything else I can supply that would help? – Veronica Aug 02 '19 at 15:50
  • 1
    I don't follow what you mean. You described your schema in your question so you know what your data looks like. I'm just asking that you write some Gremlin to create sample data that people can use to help answer your question. Providing sample data makes it easy to give you an answer with a fully tested traversal that doesn't rely on assumptions that can be taken from your schema description. – stephen mallette Aug 02 '19 at 16:04

1 Answers1

0

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

g.V().hasLabel('Community').
  group().
    by('name').
    by(__.in('belongsTo').values('id').fold())
Daniel Kuppitz
  • 10,846
  • 1
  • 25
  • 34