You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

ArangoDB如何实现任意深度节点关系查询?

Open-Ended Depth Traversal in ArangoDB

Absolutely! ArangoDB supports open-ended depth ranges similar to Neo4j's * syntax—you just need to tweak your AQL query slightly.

In AQL, to specify a traversal with a minimum depth and no upper limit (equivalent to Neo4j's 1..*), you can use the syntax 1.. (only define the start depth, omit the end value).

Modified AQL Query

Here's how your original query would look to allow unlimited maximum depth:

FOR v,e,p IN 1.. INBOUND 'emps/1386821' GRAPH 'Heirarchy'
  OPTIONS { bfs : true} 
  RETURN p

Extra Notes on Depth Syntax

  • If you want to include all depths starting from 0 (no lower or upper limit), you can use either .. or * as the depth range:
    # Both of these work for unbounded traversal from depth 0
    FOR v,e,p IN .. INBOUND 'emps/1386821' GRAPH 'Heirarchy' OPTIONS { bfs : true} RETURN p
    FOR v,e,p IN * INBOUND 'emps/1386821' GRAPH 'Heirarchy' OPTIONS { bfs : true} RETURN p
    
  • This matches the behavior of your Neo4j example, where * in the relationship pattern (<-[:ReportsTo *]-) allows traversing any number of hops from the starting node.

内容的提问来源于stack exchange,提问作者Ashok Mandal

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.20 10:10:06