Gremlin Python:查询一个列表和那个 returns key/value 列表

Gremlin Python: Query a list and that returns key/value list

我想查询一个列表,查询响应必须return给我列表项的哪个响应。

例如:

a = [1,2,3]

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

以上查询的响应是:

[1232131, 4322334, 124334, 354454, 23423423]

我想要的回复是:

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

我只是不想在 python 的 for 循环中这样做。是否可以使用 gremlin-python?

我认为你只需要group()你的结果:

g.V().has("cid", "value", P.within(a)).
  group().
    by('cid').
    by(__.in_('o_f_c').out('o_f_c').values().fold()).
  toList()