zra
zra

Reputation: 141

ArangoDB: AQL query to get all edges between two specific nodes

I have a document collection 'node' and an edge collection 'attribute'. I am trying to get all edges in 'attribute' collection from: 'node/582148' to: 'node/582016'.

The simplest AQL query I've been able to devise is the following:

FOR v, e, p IN OUTBOUND 'node/582148' `attribute`
    FILTER e._to == 'node/582016'
    RETURN p

Is there really no way to do this in one, like:

FOR v, e, p IN OUTBOUND 'node/582148' TO 'node/582016' `attribute` RETURN p

It's only possible to use the 'TO' keyword with SHORTEST_PATH. To clarify: I am only interested in direct paths (1 edge) between the nodes

thanks

Upvotes: 3

Views: 2186

Answers (1)

Maximilian Kernbach
Maximilian Kernbach

Reputation: 571

Using graph traversal i would recommend to use the following AQL query to get all outgoing edges, which is filtering by the target vertex key:

FOR v, e IN OUTBOUND 'node/582148' `attribute`
FILTER v._key == '582016'
RETURN e

Another approach is to address the edge as a document with attributes _from and _to without graph traversal:

FOR e IN `attribute`
FILTER e._from == 'node/582148' && e._to == 'node/582016'
RETURN e

Upvotes: 3

Related Questions