簡體   English   中英

在 gremlin 查詢中顯示級別

[英]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())

示例: https://gremlify.com/ca32zczgvtkh6

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM