[英]Displaying level in gremlin query
I am executing the gremlin query as follows:我正在执行 gremlin 查询,如下所示:
gV().hasLabel('A').has('label_A','A').emit().repeat(outE().inV()).valueMap()
Getting the desired output of nodes at multiple levels.在多个级别获取所需的 output 个节点。
Along with the properties, I want to add a level property to the output. How can I achieve it?除了属性之外,我还想向 output 添加一个级别属性。我该如何实现?
Adding another answer to point out you can avoid sack
using loops
as an alternative.添加另一个答案以指出您可以避免sack
使用loops
作为替代方法。
g.V().hasLabel('A').has('label_A','A').
emit().
repeat(group('x').by(loops()).by(valueMap().fold()).out()).
cap('x')
You can use withSack
for depth:您可以使用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())
example: https://gremlify.com/ca32zczgvtkh6示例: https://gremlify.com/ca32zczgvtkh6
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.