我正在执行gremlin查询,如下所示。
g.V().hasLabel('A').has('label_A','A').emit().repeat(outE().inV()).valueMap()
获取所需的多级节点的输出。
除了属性之外,我还想在输出中添加一个级别属性。如何实现?
你可以使用 withSack
为深度。
g.withSack(0).V().hasLabel('A').has('label_A','A').emit().
repeat(sack(sum).
by(constant(1)).
out()).
project('depth', 'properties').
by(sack()).
by(valueMap())
增加另一个答案,指出你可以避免。sack
使用 loops
作为一种选择。
g.V().hasLabel('A').has('label_A','A').
emit().
repeat(group('x').by(loops()).by(valueMap().fold()).out()).
cap('x')