[SERVER-6612] Support projecting multiple array values in a projection like the $elemMatch projection specifier Created: 26/Jul/12 Updated: 06/Dec/22 Resolved: 17/Jan/18 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Querying |
| Affects Version/s: | 2.2.0-rc0 |
| Fix Version/s: | None |
| Type: | New Feature | Priority: | Major - P3 |
| Reporter: | Ben Becker | Assignee: | Backlog - Query Team (Inactive) |
| Resolution: | Duplicate | Votes: | 37 |
| Labels: | projection | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||||||||||||||||||||||
| Assigned Teams: |
Query
|
||||||||||||||||||||||||||||
| Backwards Compatibility: | Fully Compatible | ||||||||||||||||||||||||||||
| Participants: | |||||||||||||||||||||||||||||
| Description |
|
The idea is to support a projection specifier like $elemMatch, but which can return multiple results from a single array. Something like $elemMatchAll or $elemMatchAny might make sense, but the projection syntax will need to be thoroughly vetted. |
| Comments |
| Comment by Asya Kamsky [ 08/Nov/15 ] | |||||||||||||||||||
|
As of 3.2 this is possible in the aggregation framework directly via the $filter expression in $project. See | |||||||||||||||||||
| Comment by Miroslav Nedyalkov [ 17/Jun/15 ] | |||||||||||||||||||
|
This works perfect, but doesn't it hurt the performance? It projects the collection and makes set difference just to filter it out. | |||||||||||||||||||
| Comment by Jon Rangel (Inactive) [ 16/Jan/15 ] | |||||||||||||||||||
|
As a workaround, I found it's possible to get the same projection behaviour using the aggregation framework:
|