Home:ALL Converter>Finding top N entries per group in Arango

Finding top N entries per group in Arango

Ask Time:2021-09-22T05:22:28         Author:nfmcclure

Json Formatter

I'm trying to efficiently find the top entries by group in Arango (AQL). I have a fairly standard object collection and an edge collection representing Departments and Employees in that department.

Example purpose: Find the top 2 employees in each department by most years of experience.

Sample Data:

"departments" is an object collection. Here are some entries:

_id name
departments/1 engineering
departments/2 sales

Author:nfmcclure,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/69275697/finding-top-n-entries-per-group-in-arango
yy