ArangoDB: Count Counting by Bypass Chart

In my ArangoDB graph, I have a theme, message flows associated with this object, and messages inside these message flows. I would like to cross the graph so that I return the data associated with the message flow, as well as the number of messages within the message flow.

The data is structured quite simply: I have a node theme, an edge extending to the node stream with the associated date and category, and an edge from the node stream to the node message.

I would like to return the data stored in the node stream and the number of messages attached to the stream.

I am not sure how to do this with the syntax for v, e, p in 1..2 outbound . Should I just do for v, e, p in outbound with a nested graph inside it? Does it still work?

+6
source share
1 answer

Sorry for the delay, we are working a lot on release 3.1;)

I think that you have already found the right solution: It is impossible to express what you would like to achieve in instruction 1..2 OUTBOUND . This is easier to state in two operations 1..1 OUTBOUND .

From your explanation, I think the following query is what you will use:

 FOR thread IN 1 OUTBOUND @start @@threadEdges LET nr = COUNT(FOR message IN 1 OUTBOUND thread @@messageEdges RETURN 1) RETURN { date: thread.date, category: thread.category, messages: nr } 

For some explanation: first select the associated stream. Then I do a subquery so that messages for a single thread can simply. Finally, I return the information I need.

In terms of performance: As for data access (which is most likely a bottleneck), there is no difference in FOR x IN 1..2 OUTBOUND [...] and FOR x IN 1 OUTBOUND [...] FOR y IN 1 OUTBOUND x [...] , both must look at exactly the same documents. In the latter case, query optimization may be a little slower, but the difference is below 1ms .

+7
source

All Articles