[SERVER-32419] add $sort and $size to the projection operators Created: 20/Dec/17 Updated: 16/Nov/21 Resolved: 17/Jan/18 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | New Feature | Priority: | Major - P3 |
| Reporter: | Ali Rahbari | Assignee: | Asya Kamsky |
| Resolution: | Won't Fix | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Backwards Compatibility: | Fully Compatible |
| Participants: |
| Description |
|
Working with embedded array has improved so much with introduction of $[] and $[<identifier>] in v3.6, but still there is no easy way to sort the embedded documents or get their count. Adding these two operator to the projection would eliminate need of using aggregation framework for usual tasks: db.collection.find( { field: value }, { array: {$slice: count, $sort: field, $size: newField} } ); |
| Comments |
| Comment by Ian Whalen (Inactive) [ 26/Apr/19 ] |
|
Switching "Drivers Changes Needed" from "Maybe" to "Not Needed" since this was closed as something other than Fixed. |
| Comment by Asya Kamsky [ 17/Jan/18 ] |
|
There is no plan to add additional expressions to project for find but rather we intend to eventually merge the different languages. |
| Comment by Asya Kamsky [ 28/Dec/17 ] |
|
In general we are trying to converge the languages and reduce the number of different ways to do things. When you run aggregate with $match and $project you’re not really aggregating the results so you shouldn’t see the results be significantly slower. If you are then there may be a different issue we are not aware of. |
| Comment by Ali Rahbari [ 23/Dec/17 ] |
|
Yes, but in aggregation framework, but it's much easier and nicer to have them as projection operator in regular find like we have $slice now. BTW it's not really an aggregation and it can be implemented faster here than going through aggregation pipeline. |
| Comment by Asya Kamsky [ 21/Dec/17 ] |
|
These already exist in aggregation $project stage. |
| Comment by Mark Agarunov [ 20/Dec/17 ] |
|
Hello rahbari, Thank you for the detailed example. I've set the fixVersion to "Needs Triage" for this new feature to be scheduled against our currently planned work. Updates will be posted on this ticket as they happen. Thanks, |