[英]Extract vertices from GRAPH_NEIGHBORS AQL query
I have a graph with a folder tree like structure and i want to get all vertices as leaf from specific starting point into the graph.我有一个带有类似结构的文件夹树的图形,我想将所有顶点作为叶子从特定起点获取到图形中。 I used the following AQL query :
我使用了以下 AQL 查询:
FOR V in
GRAPH_NEIGHBORS( "FolderTree",
{ "folderpath" : "/Cabinet 000001"},
{ direction : 'outbound',
maxDepth : 20,
vertexCollectionRestriction : 'Document'})
return V
The query works fine but i only get internal handle ID into results :查询工作正常,但我只在结果中获取内部句柄 ID:
["Document/4592118051","Document/4598606115","Document/4588185891",....]
I would like to have as result the list of records into collection instead of internal ID.作为结果,我希望将记录列表而不是内部 ID 放入集合中。 All internal ID belong to the same collection.
所有内部 ID 都属于同一个集合。 I am wondering if it is possible to use sub-query.
我想知道是否可以使用子查询。 I do not understand what could be the syntax.
我不明白可能是什么语法。
Regards问候
You have to pass the includeData
-option of GRAPH_NEIGHBORS
as true
.您必须将
GRAPH_NEIGHBORS
的includeData
GRAPH_NEIGHBORS
作为true
传递。
FOR V in
GRAPH_NEIGHBORS("FolderTree",
{"folderpath" : "/Cabinet 000001"},
{ direction : 'outbound',
maxDepth : 20,
vertexCollectionRestriction : 'Document',
includeData: true}
)
return V
The behaviour of GRAPH_NEIGHBORS
changed with the release of 2.6, prior versions did include all document attributes in the result, maybe you got bitten by that change. GRAPH_NEIGHBORS
的行为随着 2.6 的发布而改变,之前的版本确实在结果中包含了所有文档属性,也许你被那个变化咬了。
Thanks Tom for your input, it works fine but execution is a little slow.感谢 Tom 的输入,它运行良好,但执行速度有点慢。 I am new to Arango, i evaluate the product for a project, but i start to fall in love with Arango DB, it is a very complete DB and for now it is great.
我是 Arango 的新手,我评估了一个项目的产品,但我开始爱上 Arango DB,它是一个非常完整的 DB,现在它很棒。
For my initial question, i have found another way to do it using a temporary array.对于我最初的问题,我找到了另一种使用临时数组的方法。 It only apply if result is limited.
它仅适用于结果有限的情况。 In my case i have nearly 1000 records :
就我而言,我有近 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
This one takes 5 sec to load 1000 records and the other one 25 sec.这个加载 1000 条记录需要 5 秒,另一个需要 25 秒。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.