[SERVER-72121] Add $top/$bottom/$topN/$bottomN as expressions Created: 14/Dec/22 Updated: 24/Jan/23 |
|
| Status: | Backlog |
| Project: | Core Server |
| Component/s: | Aggregation Framework |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Task | Priority: | Minor - P4 |
| Reporter: | Katya Kamenieva | Assignee: | Backlog - Query Execution |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | expression | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||
| Assigned Teams: |
Query Execution
|
||||||||
| Participants: | |||||||||
| Description |
|
It is rather awkward that to get topN array elements, you would do $sortArray+$slice while there's topN accumulator available. Proposing: $topN: {input: <expression resolving to array>, n: <n expression>, sortBy: <spec>} e.g.:
|