2
votes

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 :

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 :

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

I would like to have as result the list of records into collection instead of internal ID. All internal ID belong to the same collection. I am wondering if it is possible to use sub-query. I do not understand what could be the syntax.

Regards

2

2 Answers

1
votes

You have to pass the includeData-option of GRAPH_NEIGHBORS as 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.

0
votes

Thanks Tom for your input, it works fine but execution is a little slow. 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.

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 :

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.