[SERVER-9030] Aggregation using $match and $project Created: 20/Mar/13 Updated: 10/Dec/14 Resolved: 20/Mar/13 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | None |
| Affects Version/s: | 2.2.3 |
| Fix Version/s: | None |
| Type: | Question | Priority: | Major - P3 |
| Reporter: | Kurt Agius | Assignee: | Michael Grundy |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Participants: |
| Description |
|
I have the following following collection:
I try to run an aggregate to match a particular unitStatus, and project every record basically with just the _id and unitStatus (not other fields). I expected to have only 1 document as a result but i get everything. Am i doing something wrong ? or is this a bug?
|
| Comments |
| Comment by Kurt Agius [ 20/Mar/13 ] | ||||||
|
Hi Michael, Thanks, apparently the examples i saw here you put the pipline in an Array were for the nodejs driver. | ||||||
| Comment by Michael Grundy [ 20/Mar/13 ] | ||||||
|
Hi Kurt - You don't need to pass the pipeline as an array []. You'll get the expected results with this:
In the future, I'd recommend posting a question like this on one of our free support channels. Filing tickets under the SERVER project is not the best way to get visibility for issues you encounter, as we use this project for tracking bugs and feature requests. If you have a support contract with 10gen, then filing commercial support tickets is your best option. If not, the 10gen development and support teams actively monitor posts to stackoverflow (http://stackoverflow.com/questions/tagged/mongodb) and to the mongo google group (https://groups.google.com/forum/?fromgroups#!forum/mongodb-user) Thanks! | ||||||
| Comment by Kurt Agius [ 20/Mar/13 ] | ||||||
|
Thanks for the very detailed explanation will definitely keep this in mind for later. | ||||||
| Comment by Tad Marshall [ 20/Mar/13 ] | ||||||
|
The two formatting "macros" that we use most often are "code" and "noformat". Each of these should be on a separate line and enclosed in wavy braces like {code} and {noformat}. In the previous sentence, I 'escaped" the wavy braces with backslash to keep them from being interpreted by the Jira display code. You use them in pairs; one before the text you want to keep from being treated as normal text by Jira and one after. {code} will display the entire quoted block while {noformat} will create a fixed size block with a scrollbar. {code} is best for short snippets, {noformat} is best for longer ones. Both macros will preserve indentation, which is pretty helpful in JSON output and in JavaScript code excerpts. {code} example
{noformat} example
You should be able to edit your own comments after posting them, but you may not be able to change the title and description. | ||||||
| Comment by Kurt Agius [ 20/Mar/13 ] | ||||||
|
Thanks, could i have done that myself ? (especially for formatting commands) | ||||||
| Comment by Tad Marshall [ 20/Mar/13 ] | ||||||
|
I updated the title and added formatting commands to the description. | ||||||
| Comment by Kurt Agius [ 20/Mar/13 ] | ||||||
|
P.S the title is wrong. I meant to write "using $match and $project" but i can't edit the title. |