[SERVER-54359] $sort doesn't work in combination with $out Created: 05/Feb/21 Updated: 27/Oct/23 Resolved: 11/Feb/21 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Aggregation Framework |
| Affects Version/s: | 4.4.3 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Platon workaccount | Assignee: | Edwin Zhou |
| Resolution: | Works as Designed | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Attachments: |
|
| Operating System: | ALL |
| Participants: |
| Description |
|
Source collection with unsorted fields:
Results redirected to another database are not sorted. I suspect it's a bug.
Results, obtained through the cursor, are sorted. It's expected by me.
|
| Comments |
| Comment by Edwin Zhou [ 11/Feb/21 ] |
|
Thank you for the clarification. The order you're seeing in the database from the result of $out is $natural order, which is the default order returned by the query, which is what we see in your Compass screenshot. This ordering is an internal implementation feature, and you should not rely on any particular ordering of the documents. We recommend explicitly sorting when querying the collection to provide your expected results. Best, |
| Comment by Platon workaccount [ 10/Feb/21 ] |
|
SON is Python/BSON dict-like type. |
| Comment by Edwin Zhou [ 09/Feb/21 ] |
|
Thanks for reporting this behavior. I'm currently attempting to reproduce your issue but SON from the $sort stage of your pipeline appears to be invalid syntax. Could you clarify that portion? Best, |