[SERVER-47202] Support $sortByExpr aggregation pipeline stage Created: 31/Mar/20  Updated: 06/Dec/22  Resolved: 31/Mar/20

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

Type: New Feature Priority: Major - P3
Reporter: Adinoyi Omuya 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-46298 Support sorting by expressions other ... Backlog
Assigned Teams:
Query
Participants:

 Description   

Possible syntax:

{ $sortByExpr: <aggregation expression>  }

Sort by salesAmount ascending:

db.users.aggregate( [ { $sortByExpr : { $sum: { $multiply: [ "$price", "$quantity" ] } } } ] )

This will allow for what currently requires $addFields + $sort + $project.


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