2

I would like to store data that is not directly related into seperate named graphs in ArangoDB. However, there might be cases where I would want to query data from more than one of these graphs at a time.

I know that you can perform a graph traversal as below, particularly using the 'GRAPH' keyword, but is it possible to do something like 'GRAPH graphName1, graphName2' to query both at the same time?

FOR vertex[, edge[, path]]
  IN [min[..max]]
  OUTBOUND|INBOUND|ANY startVertex
  GRAPH graphName
  [OPTIONS options]

I know I could "union" the results of multiple of the above graph traversals, but given that only the graphName would be different, it would be great if I could make it concise instead of repeating redundant code.

Ponsietta
  • 315
  • 6
  • 17

1 Answers1

2

You cannot traverse multiple named graphs in a traversal. Instead you can either:

Create anew named graph with all the necessary vertex and edges

Or (better)

Traverse the collections directly without using named graphs. The performance is the same. Here is the syntax:

FOR vertex[, edge[, path]]
  IN [min[..max]]
  OUTBOUND|INBOUND|ANY startVertex
  edgeCollection1, ..., edgeCollectionN
  [PRUNE pruneCondition]
  [OPTIONS options]
camba1
  • 1,795
  • 2
  • 12
  • 18
  • Relevant documentation regarding anonymous graphs / working with collection sets: https://docs.arangodb.com/3.4/Manual/Graphs/#anonymous-graphs and https://docs.arangodb.com/3.4/AQL/Graphs/Traversals.html#working-with-collection-sets – CodeManX Mar 25 '19 at 10:33