[SERVER-8152] aggregation array sort differs from query/index array sort; causes aggregation results to change depending on sort optimizations Created: 11/Jan/13  Updated: 06/Dec/22  Resolved: 21/Jul/17

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

Type: Bug Priority: Major - P3
Reporter: Aaron Staple Assignee: Backlog - Query Team (Inactive)
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
duplicates SERVER-19402 Change semantics of sorting by array ... Closed
Related
is related to SERVER-480 figure out what to do with sorting by... Closed
is related to SERVER-19402 Change semantics of sorting by array ... Closed
Assigned Teams:
Query
Operating System: ALL
Steps To Reproduce:

c = db.c;
c.drop();
 
c.save( { _id:'x', a:[ 2, 1 ] } );
c.save( { _id:'y', a:[ 1, 2 ] } );
 
// no index                                                                                    
printjson( c.aggregate( { $sort:{ a:1 } } ) );
 
// with index                                                                                  
c.ensureIndex( { a:1 } );
printjson( c.aggregate( { $sort:{ a:1 } } ) );

Participants:

 Description   

Aggregation and queries/indexing sort arrays differently. This can cause the results returned by an aggregation to change when a sort stage is removed in favor of using an index.



 Comments   
Comment by David Storch [ 21/Jul/17 ]

This has been fixed under SERVER-19402. See the description of that ticket for additional technical details describing the fix. I'm closing this ticket as a duplicate.

Comment by Aaron Staple [ 11/Jan/13 ]

I didn't remember / find any existing references to this. Sorry if it's a dup.

Generated at Thu Feb 08 03:16:42 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.