0

I want to query a list and the query response must return to me which response of the list item.

For example:

a = [1,2,3]

graph.V().has("cid", "value", P.within(a)).in_('o_f_c').out('o_f_c').values().toList()

The response of above query is:

[1232131, 4322334, 124334, 354454, 23423423]

The response which I want is:

[[1, [1232131, 4322334]], 
[2, [124334],
[3, [354454,23423423]]

I just dont want to do that in a for loop with python. Is it possible do with gremlin-python?

Berkay
  • 91
  • 7

1 Answers1

1

I think you just need to group() your results:

g.V().has("cid", "value", P.within(a)).
  group().
    by('cid').
    by(__.in_('o_f_c').out('o_f_c').values().fold()).
  toList()
stephen mallette
  • 45,298
  • 5
  • 67
  • 135
  • Thank you so much for your response. I just changed the `by('cid')` with `by('value')` and import the `from gremlin_python.process.graph_traversal import __`. – Berkay Jun 26 '21 at 15:30