[SERVER-69239] $lastN ordering issue Created: 30/Aug/22 Updated: 30/Aug/22 Resolved: 30/Aug/22 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | None |
| Affects Version/s: | 6.0.1 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Justin Lee | Assignee: | Yuan Fang |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||
| Operating System: | ALL | ||||||||
| Steps To Reproduce: | Simply click the copy buttons for the data and the pipeline and see the results. |
||||||||
| Participants: | |||||||||
| Description |
|
If I run the example here: https://www.mongodb.com/docs/manual/reference/operator/aggregation/lastN/#computing-n-based-on-the-group-key-for–group, I get the following results: { "_id" : \{ "gameId" : "G1" }, "gamescores" : [ 33, 99, 1 ] } { "_id" : \{ "gameId" : "G2" }, "gamescores" : [ 80 ] } But the docs show, correctly, that for G2 there should be only a 10 there. I'm literally using the 'copy' action on the page and pasting in to my local shell and getting those results. Am I tripping or is there a bug here? server build info as follows: db.serverBuildInfo() , , |
| Comments |
| Comment by Justin Lee [ 30/Aug/22 ] | ||||||||
|
Fabulous. I was curious if that was the case. I'll update bits on my end, too. Thank you for confirming. | ||||||||
| Comment by Yuan Fang [ 30/Aug/22 ] | ||||||||
|
Thank you for reporting this. After an investigation, I found an error in the document you referred to: The result of Computing n Based on the Group Key for $group (without using $sort in descending order) that is shown in the document:
should be corrected to:
The results you got are actually correct. I've created a Jira ticket Regards, Yuan
|