How to query for a specific combination of nodes in Arango DB graph

28 views
Skip to first unread message

Malsha Ranawaka

unread,
Jul 11, 2018, 6:37:37 AM7/11/18
to ArangoDB
Hi All,

I posted this question on stackoverflow as well but could not resolve it, so am posting it here again. 

I have a graph containing two vertex collections: Attraction (green) and Hotel (orange).

I want to query for a certain combination of Attractions and Hotels, such as the one given below:


Attraction (start vertex) ---> Attraction ---> Hotel
                                   |
                                   |
                                   v
                               Attraction


Graph has directed edges as shown.

The query I have now (below) gives any part of the above combination, instead of four nodes connected exactly as above.


FOR document IN Attraction FOR vertex, edge, path IN 1..2 OUTBOUND document GRAPH "LondonAttractionDB" 
FILTER path.vertices[0].entityTypes[0] == "Attraction" 
FILTER path.vertices[1].entityTypes[0] == "Attraction" 
FILTER path.vertices[2].entityTypes[0] == "Hotel" OR path.vertices[2].entityTypes[0] == "Attraction" 
RETURN path


Please see the attached image for the result generated by the above query.


Above query gives all combinations containing two, three or four nodes as shown in attached image. How can I get only the results (combinations of exactly four nodes) shown within circles?


Any help is much appreciated.


Thanks.


8Ykog.png

Simran Brucherseifer

unread,
Jul 11, 2018, 10:02:29 AM7/11/18
to ArangoDB
Please keep this on StackOverflow and reply to the open question (third comment)
Reply all
Reply to author
Forward
0 new messages