[SERVER-60781] $topN results not returned in order according to sort spec Created: 18/Oct/21  Updated: 29/Oct/23  Resolved: 27/Oct/21

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: 5.2.0

Type: Task Priority: Major - P3
Reporter: Mickey Winters Assignee: Mihai Andrei
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Backwards Compatibility: Fully Compatible
Sprint: QE 2021-11-01
Participants:

 Description   

With the current implementation $bottomN returns results in the order you would get by using a $sort stage with the same sort spec, but $topN does not. $topN currently returns results in the order opposite of the sort spec, e.g. {a: 1} currently returns the largest $a first whereas a $sort stage would return the smallest $a first.

Pending on going discussion of result ordering in the Exact Top N Accumulator project, we should update AccumulatorTopBottomN to reflect that decision and change all the tests.



 Comments   
Comment by Githook User [ 27/Oct/21 ]

Author:

{'name': 'Mihai Andrei', 'email': 'mihai.andrei@10gen.com', 'username': 'mtandrei'}

Message: SERVER-60781 Modify $top/$topN/$bottom/$bottomN accumulators to return results according to order specified by 'sortBy'
Branch: master
https://github.com/mongodb/mongo/commit/e008629280f2b154244cf0fd9e6d67e83b4dcb10

Generated at Thu Feb 08 05:50:43 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.