Re: Re: printing data other than in mongo using aggregation frame work

From: Asya Kamsky <asya@xxxxxxxxxxx>
To: mongodb-user <mongodb-user@xxxxxxxxxxxxxxxx>
Date: Wed, 27 Apr 2016 13:58:45 -0700
Why ads?
Amar is right, but I would add to that that you should remove the
$project stage.

Your $project stage is not doing anything useful so it's going to slow
down performance of the pipeline.  Aggregation already examines the
pipeline to see which fields it needs to output the final result so
using $project to "prune down" the fields is counter-productive.

Asya


On Tue, Apr 26, 2016 at 4:41 AM, Amar Singh <amar09108@xxxxxxxxx> wrote:
By default $group gives only the the grouped field value. You can use
$first, $last, $push for getting other fields.

One example could be like this

db.test.aggregation({"$project": "status":1,"cost":1 },{"$group":{_id:
"name","cost"},"status":{"$first":"$status"}})

You can use other operators as well.


Amar Singh

On Mon, Apr 25, 2016 at 12:48 PM, Rhys Campbell
<rhys.james.campbell@xxxxxxxxx> wrote:

Provide a few sample documents.

--
You received this message because you are subscribed to the Google Groups
"mongodb-user"
group.

For other MongoDB technical support options, see:
https://docs.mongodb.org/manual/support/
---
You received this message because you are subscribed to the Google Groups
"mongodb-user" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to mongodb-user+unsubscribe@xxxxxxxxxxxxxxxx.
To post to this group, send email to mongodb-user@xxxxxxxxxxxxxxxx.
Visit this group at https://groups.google.com/group/mongodb-user.
To view this discussion on the web visit
https://groups.google.com/d/msgid/mongodb-user/71cbb709-588b-4d29-b31f-f69168a26110%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.


--
You received this message because you are subscribed to the Google Groups
"mongodb-user"
group.

For other MongoDB technical support options, see:
https://docs.mongodb.org/manual/support/
---
You received this message because you are subscribed to the Google Groups
"mongodb-user" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to mongodb-user+unsubscribe@xxxxxxxxxxxxxxxx.
To post to this group, send email to mongodb-user@xxxxxxxxxxxxxxxx.
Visit this group at https://groups.google.com/group/mongodb-user.
To view this discussion on the web visit
https://groups.google.com/d/msgid/mongodb-user/CAA1QGCCbSAuUrMcfDRmbU7tHuW-pd8YY%2B3s%2BRWzQ9BZXf%3DU_5g%40mail.gmail.com.

For more options, visit https://groups.google.com/d/optout.



-- 
Asya Kamsky
Lead Product Manager
MongoDB
Download MongoDB - mongodb.org/downloads
Free MongoDB Monitoring - cloud.mongodb.com
Free Online Education - university.mongodb.com
Get Involved - mongodb.org/community
We're Hiring! - https://www.mongodb.com/careers

-- 
You received this message because you are subscribed to the Google Groups "mongodb-user"
group.

For other MongoDB technical support options, see: https://docs.mongodb.org/manual/support/
--- 
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongodb-user+unsubscribe@xxxxxxxxxxxxxxxx.
To post to this group, send email to mongodb-user@xxxxxxxxxxxxxxxx.
Visit this group at https://groups.google.com/group/mongodb-user.
To view this discussion on the web visit https://groups.google.com/d/msgid/mongodb-user/CAOe6dJDnd6MeQRovyibhiTq030GSs_NXRz%3DqF697m%3D75MJzB9A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Why ads?