[SERVER-5781] Implement $addFields aggregation stage for using expression language to add new fields to a document Created: 07/May/12 Updated: 22/Mar/17 Resolved: 12/Aug/16 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Aggregation Framework |
| Affects Version/s: | None |
| Fix Version/s: | 3.3.11 |
| Type: | New Feature | Priority: | Major - P3 |
| Reporter: | Patrick Kaeding | Assignee: | Carly Robison |
| Resolution: | Done | Votes: | 26 |
| Labels: | stage, usability | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Backwards Compatibility: | Fully Compatible | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Sprint: | Integration 2016-08-29 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Participants: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Linked BF Score: | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Description |
| Comments |
| Comment by Max Hirschhorn [ 12/Aug/16 ] | ||||
|
Re-resolving this ticket. The memory leak will be fixed under | ||||
| Comment by Max Hirschhorn [ 12/Aug/16 ] | ||||
|
Reopening to address a memory leak when deleting the DocumentSource created for the $addFields stage. | ||||
| Comment by Githook User [ 11/Aug/16 ] | ||||
|
Author: {u'username': u'carlyrobison', u'name': u'Carly Robison', u'email': u'crobison@caltech.edu'}Message: | ||||
| Comment by Githook User [ 11/Aug/16 ] | ||||
|
Author: {u'username': u'carlyrobison', u'name': u'Carly Robison', u'email': u'crobison@caltech.edu'}Message: Revert " This reverts commit 4fc451a03f06b696ec563144385aabe2d3d619cf. | ||||
| Comment by Githook User [ 11/Aug/16 ] | ||||
|
Author: {u'username': u'carlyrobison', u'name': u'Carly Robison', u'email': u'crobison@caltech.edu'}Message: | ||||
| Comment by Githook User [ 11/Aug/16 ] | ||||
|
Author: {u'username': u'carlyrobison', u'name': u'Carly Robison', u'email': u'crobison@caltech.edu'}Message: | ||||
| Comment by Githook User [ 11/Aug/16 ] | ||||
|
Author: {u'username': u'carlyrobison', u'name': u'Carly Robison', u'email': u'crobison@caltech.edu'}Message: This aggregation stage allows the addition of computed fields to a document while preserving all existing fields. | ||||
| Comment by Carly Robison [ 10/Aug/16 ] | ||||
|
We need a page for this new aggregation stage. Additionally, our courseware (when updated to 3.4) should use $addFields instead of $project: {<literally every field in the collection>: 1} | ||||
| Comment by Jose Antonio Illescas Olmo [ 26/Apr/16 ] | ||||
|
I know about $$ROOT. But this solution required a "custom" JSON structure that I prefer avoid (I like control my JSON structure) | ||||
| Comment by Asya Kamsky [ 25/Apr/16 ] | ||||
|
Note that there is a limited workaround currently available via $$ROOT system variable. You can preserve incoming document and add other fields, however the original fields and added fields would be on different levels, which is why this feature request exists, it's to be able to add fields to existing document on the same level. Example:
| ||||
| Comment by Jose Antonio Illescas Olmo [ 25/Apr/16 ] | ||||
|
Another Use Case: I define a calculated field "desc2" for every document... I add "desc" field to any document: · "desc" sometimes is a simple field or a concatenation of many fields (each with i18n format) I need add this field without remove the rest of my document fields | ||||
| Comment by Jose Antonio Illescas Olmo [ 12/Apr/16 ] | ||||
|
I need this feature, currently it's mandatory declare all fields to add new computed fields note1: in my REST services I provide a calculated i18n description for every document to allows their use on html-select, also I overwrite "_id" as "id" and plainify as string. note2: another feature is remove fields: all my documents contains "lastModified" date exposed as Last-Modified http-header (coditional get and put) => this field must be removed from document/json content Thank you | ||||
| Comment by Thomas Rueckstiess [ 02/Jul/14 ] | ||||
|
I'm voting for this feature, too. Use Case: I have several $unwind / $group stages in my pipeline, each calculating some values. I'd like to preserve intermediate results all the way to the end of the pipeline, but I don't know which variables those are up front. Therefore, I'd like to have a "results" sub-document that I can just push the results into as sub-documents, and each $project and $group stage would just have to ensure that the "results" sub-document is preserved. |