2

我有一个带有文件夹树状结构的图,我想将所有顶点作为叶子从特定起点获取到图中。我使用了以下 AQL 查询:

FOR V in 
      GRAPH_NEIGHBORS( "FolderTree",
                       { "folderpath" : "/Cabinet 000001"},
                       { direction : 'outbound', 
                         maxDepth : 20,
                         vertexCollectionRestriction : 'Document'})
return V

查询工作正常,但我只将内部句柄 ID 放入结果中:

["Document/4592118051","Document/4598606115","Document/4588185891",....]

我希望将记录列表而不是内部 ID 作为结果。所有内部 ID 属于同一个集合。我想知道是否可以使用子查询。我不明白语法可能是什么。

问候

4

2 回答 2

1

您必须传递as的includeData-option 。GRAPH_NEIGHBORStrue

FOR V in 
  GRAPH_NEIGHBORS("FolderTree",
                   {"folderpath" : "/Cabinet 000001"},
                   { direction : 'outbound',
                     maxDepth : 20,
                     vertexCollectionRestriction : 'Document',
                     includeData: true}
   ) 
return V

随着 2.6 版本的发布,行为发生了GRAPH_NEIGHBORS变化,之前的版本确实在结果中包含了所有文档属性,也许你被那个变化咬住了。

于 2015-10-07T07:51:13.827 回答
0

感谢 Tom 的输入,它运行良好,但执行速度有点慢。我是 Arango 的新手,我为一个项目评估产品,但我开始爱上 Arango DB,它是一个非常完整的 DB,现在它很棒。

对于我最初的问题,我找到了另一种使用临时数组的方法。它仅适用于结果有限的情况。就我而言,我有近 1000 条记录:

LET docs = (FOR V in  GRAPH_NEIGHBORS("FolderTree",{"folderpath" : "/Cabinet 000001"},{direction : 'outbound', maxDepth : 10,vertexCollectionRestriction : 'Document'}) RETURN V)
FOR docid in docs
  FOR doc in Document
  FILTER doc._id==docid
  return doc

这个需要 5 秒来加载 1000 条记录,另一个需要 25 秒。

于 2015-10-07T09:17:18.987 回答