'ArangoDB : Prune the traverse query after getting some number of connected vertices

Background:

We have a requirement to do some logic when the data have connected vertices more than certain number. for the example the number of connected vertices on the data is 1000, but the requirement only to get the first 5 vertices, and dont care about the rest.

Current solution:

We do perform regular AQL traversal query to get connected vertices according to our criteria, and we got all the connected vertices data.

Problem:

If the data have thousands or more of graph connections, the traversal query took a long time...

Question:

Is it possible to set prune based on count? so if the traversal query already getting 5 count, then stop the traversal process



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source