[英]Displaying level in gremlin query
我正在執行 gremlin 查詢,如下所示:
gV().hasLabel('A').has('label_A','A').emit().repeat(outE().inV()).valueMap()
在多個級別獲取所需的 output 個節點。
除了屬性之外,我還想向 output 添加一個級別屬性。我該如何實現?
添加另一個答案以指出您可以避免sack
使用loops
作為替代方法。
g.V().hasLabel('A').has('label_A','A').
emit().
repeat(group('x').by(loops()).by(valueMap().fold()).out()).
cap('x')
您可以使用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())
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.