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
相关产品推荐
相关产品推荐

