Top "Aggregation-framework" questions

The MongoDB Aggregation Framework provides a means to reshape and aggregate data in MongoDB 2.2+.

Retrieve only the queried element in an object array in MongoDB collection

Suppose you have the following documents in my collection: { "_id":ObjectId("562e7c594c12942f08fe4192"), "shapes":[ { "shape":"square", "color":"…

mongodb mongodb-query aggregation-framework projection
MongoDB: Combine data from multiple collections into one..how?

How can I (in MongoDB) combine data from multiple collections into one collection? Can I use map-reduce and if so …

mongodb mongodb-query aggregation-framework
MongoDB SELECT COUNT GROUP BY

I am playing around with MongoDB trying to figure out how to do a simple SELECT province, COUNT(*) FROM contest …

mongodb group-by aggregation-framework
Update MongoDB field using value of another field

In MongoDB, is it possible to update the value of a field using the value from another field? The equivalent …

mongodb mongodb-query aggregation-framework
Get names of all keys in the collection

I'd like to get the names of all the keys in a MongoDB collection. For example, from this: db.things.…

mongodb mongodb-query aggregation-framework
mongodb group values by multiple fields

For example, I have these documents: { "addr": "address1", "book": "book1" }, { "addr": "address2", "book": "book1" }, { "addr": "address1", "book": "book5" }, { "addr": "address3", "…

mongodb aggregation-framework
mongodb count num of distinct values per field/key

Is there a query for calculating how many distinct values a field contains in DB. f.e I have a …

mongodb mongodb-query aggregation-framework
How to filter array in subdocument with MongoDB

I have array in subdocument like this { "_id" : ObjectId("512e28984815cbfcb21646a7"), "list" : [ { "a" : 1 }, { "a" : 2 }, { "a" : 3 }, { "a" : 4 }, { "a" : 5 } ] } Can I …

mongodb filter mongodb-query aggregation-framework
$lookup on ObjectId's in an array

What's the syntax for doing a $lookup on a field that is an array of ObjectIds rather than just a …

mongodb mongodb-query aggregation-framework
Find duplicate records in MongoDB

How would I find duplicate fields in a mongo collection. I'd like to check if any of the "name" fields …

mongodb aggregation-framework database