[SERVER-19259] $project expressions not working for documents inside arrays Created: 02/Jul/15 Updated: 03/Aug/15 Resolved: 03/Aug/15 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Aggregation Framework |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | guru rajan | Assignee: | Unassigned |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Attachments: |
|
|||||||||||
| Operating System: | ALL | |||||||||||
| Steps To Reproduce: |
|
|||||||||||
| Participants: |
| Description |
|
Match condition is not working inside projection for Embedded dcouments |
| Comments |
| Comment by Ramon Fernandez Marina [ 03/Aug/15 ] | ||||||||||||||
|
guruskec, if you run:
you'll see that the result documents look like this:
so to get the behavior you're looking for you need to take this into account and do
Please note that this only works when $salary.amount has one element. Since one can't reach into an array via dot notation in the projection stage we've added an array indexing operator in Regards, | ||||||||||||||
| Comment by guru rajan [ 02/Jul/15 ] | ||||||||||||||
|
Please ignore Query 2 and use the below db.salary.aggregate([{"$project":{"_id":0,"agreementNo":1,MI: {"$gte": ["$salary.amount", 6000]}}} ]).toArray(); | ||||||||||||||
| Comment by Ramon Fernandez Marina [ 02/Jul/15 ] | ||||||||||||||
|
guruskec, the values.json file does not contain any documents that satisfy the $match condition of the second aggregation pipeline. Can you please upload documents that do along with a description of the behavior you expect? Thanks, |