[SERVER-7618] New aggregation expression: generator for serial numbers Created: 11/Nov/12 Updated: 06/Dec/22 Resolved: 04/Feb/16 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Aggregation Framework |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | New Feature | Priority: | Minor - P4 |
| Reporter: | Richard Kreuter (Inactive) | Assignee: | Backlog - Query Team (Inactive) |
| Resolution: | Duplicate | Votes: | 0 |
| Labels: | expression | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||
| Assigned Teams: |
Query
|
||||||||
| Participants: | |||||||||
| Description |
|
It might be nice if the agg. framework had expressions in $project for generating things like sequential numbers. Here's one use for such a thing: given some inputs of the form { A : <Avalue>, B : <Bvalue> }produce groupings on A values, remove exactly 1 instance of the minimum B value per group. (AFAICT, this problem can't be solved yet in the aggregation framework.) If $project could join serial numbers into those inputs, then it would be possible by constructing a unique minimum Bvalue subdocument like this:
Of course there are other (and probably better) aggregation extensions that would solve this problem, but the requested feature both helps with this one and might be useful elsewhere. (In the made-up $generate expression above, I stuck the keyword $serial in there in case it turns out to be useful to have things other than serial numbers in future, e.g., random numbers, ObjectIds, timestamps, etc.) Doc changes: if we do it, we oughtta doc it. |
| Comments |
| Comment by Charlie Swanson [ 04/Feb/16 ] | ||||||||||
|
I believe this could be addressed in a simpler way via e.g. you could do something like the following (making up a syntax):
Closing as a duplicate. Feel free to let me know if you disagree. | ||||||||||
| Comment by Charlie Swanson [ 04/Feb/16 ] | ||||||||||
|
asya I believe this is separate from |