[SERVER-36261] Support field projection based on string inside of field name Created: 24/Jul/18 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: | Aaron Kerti | Assignee: | Backlog - Query Optimization |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||||||
| Assigned Teams: |
Query Optimization
|
||||||||||||
| Participants: | |||||||||||||
| Description |
|
Suppose you have documents that look similar to this:
Fields in a document may start with "PRE-" and have any characters after that. During the projection stage, I want to be able to project all fields that contain the string "PRE-". Maybe the project statement looks something like this:
|
| Comments |
| Comment by Asya Kamsky [ 03/Aug/18 ] | ||||||||||||||||
|
You can do this currently with aggregation if you can express the regular expression as simple substring match. For simple cases like the prefix comparison with sample document you provided, you can do this:
This ticket is more directly related to SERVER-267 which asks for support of wildcards in queries, projections and indexes - though that's not specific to aggregation $project stage. | ||||||||||||||||
| Comment by Nick Brewer [ 25/Jul/18 ] | ||||||||||||||||
|
akerti On looking at this closer I can see that your request is a little different, as you're trying to match against field names as opposed to values. I'm passing this along to our Query team as a feature request. -Nick | ||||||||||||||||
| Comment by Nick Brewer [ 25/Jul/18 ] | ||||||||||||||||
|
akerti I believe the behavior you're describing is covered as part of a larger ticket for adding enhanced regex support to the aggregation pipeline: You can follow along with that ticket for updates on the status of this work. -Nick |