ArangoDB Join Edge collections

265 views Asked by At

I have 1 node and two edge collections. I want to write an AQL query to find the common nodes between the two edge collections. How can I join two edge collections as there is not common field in the 2 edge collections to query. As I am trying to find nodes the common node ids can exist either is _from or _to fields

Let’s say I have 2 edges in 2 different edges collections as the following : Edge-1 : _from: A1 _to: B1 Edge-2 : _from: B1 _to: C2

The output would be B1 because it is common among the two edge collections

1

There are 1 answers

3
Yevgeniy On

following query would return B1:

FOR e1 IN edge_1
FOR e2 IN edge_2
FILTER e1._to == e2._from
FOR n IN nodes
FILTER n._id == e1._to
RETURN DISTINCT n