How to grouping and aggregation using Gremlin

35 Views Asked by At
  1. we have part vertex and job vertex
  2. parts vertex linked to job vertex with relationship 'parts used in job'
  3. I have a set of parts as input say 10 parts. For these 10 parts can you identify possible jobs. The output I need is like job1: "[Part1,Part2,part3]" job2: "[part2,part4]"

{"gremlin":"g.V().hasLabel('Parts').has('~id', within('2197001','6D9157','6V8636','336027','6V3831','2554534','2531351')).as('part').out('part_used_in_job').as('job').select('job', 'part').group().by('job').by(select('part').values('~id').fold())"} {'detailedMessage': 'java.util.LinkedHashMap cannot be cast to org.apache.tinkerpop.gremlin.structure.Element', 'requestId': '49551d9e-e22f-4e92-99bc-77fbf1b1784b', 'code': 'UnsupportedOperationException', 'message': 'java.util.LinkedHashMap cannot be cast to org.apache.tinkerpop.gremlin.structure.Element'} """

g.V().hasLabel('Parts').has('~id', within('2197001','6D9157','6V8636','336027','6V3831','2554534','2531351'))
  .as('part')
  .out('part_used_in_job')
  .as('job')
  .select('job', 'part')
  .group()
    .by('job')
    .by(select('part').values('~id').fold())

"""

0

There are 0 best solutions below