[SERVER-15697] Create a string accumulator for aggregation Created: 16/Oct/14 Updated: 06/Dec/22 |
|
| Status: | Backlog |
| Project: | Core Server |
| Component/s: | Aggregation Framework |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | New Feature | Priority: | Major - P3 |
| Reporter: | GERVAIS Mickaël | Assignee: | Backlog - Query Execution |
| Resolution: | Unresolved | Votes: | 1 |
| Labels: | accumulator, expression, pm1457-nominee | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||||||||||
| Assigned Teams: |
Query Execution
|
||||||||||||||||
| Participants: | |||||||||||||||||
| Description |
|
Hi, I'd like to join all elements in an array in a aggregation. Thanks |
| Comments |
| Comment by Asya Kamsky [ 11/Aug/21 ] | |||||||||||||
|
This can also track expression for "join" (like JS or Python join for strings with optional join character).
| |||||||||||||
| Comment by Asya Kamsky [ 13/Sep/17 ] | |||||||||||||
|
Leaving the ticket open to track whether we want to create a $group accumulator "$concat". | |||||||||||||
| Comment by Asya Kamsky [ 13/Sep/17 ] | |||||||||||||
|
As of 3.4 it's possible to do this via $reduce something like this:
| |||||||||||||
| Comment by Asya Kamsky [ 02/Aug/15 ] | |||||||||||||
|
Suggest we use this ticket to track operator equivalent to concat strings in array. It's possible that if | |||||||||||||
| Comment by Ramon Fernandez Marina [ 21/Oct/14 ] | |||||||||||||
|
Thanks for following up mgervais, we've marked this ticket to be considered for future improvements in the aggregation framework. | |||||||||||||
| Comment by GERVAIS Mickaël [ 21/Oct/14 ] | |||||||||||||
|
Hi, Thanks for your responses. Asya has given a good example. I've an array of string, and I need to concatenate values with a separator (or not) to generate a key and check if this key exists in a map of rules. In Java lambda, it's possible to reduce values by concatenating them. Have I been clear enough ? | |||||||||||||
| Comment by Asya Kamsky [ 18/Oct/14 ] | |||||||||||||
|
I can see it being useful - if you have something like:
I've made an assumption that "$concat" would work the way "$sum" does currently, though given that we use $sum and not $add maybe it makes sense for concatenating operator to be named something different from the project operator. | |||||||||||||
| Comment by Ramon Fernandez Marina [ 17/Oct/14 ] | |||||||||||||
|
mgervais, can you provide a more detailed example of the kind of data you have and how would you like to manipulate it with this new hypothetical aggregation operator? Sample input and output would help clarify what is it you need, and whether there are alternative ways to do it. Thanks, |