difference between aggregate ($match) and find, in MongoDB? -
what difference between $match
operator used inside aggregate function , regular find
in mongodb?
why doesn't find
function allow renaming field names aggregate function? e.g. in aggregate can pass following string:
{ "$project" : { "ordernumber" : "$purchaseorder.ordernumber" , "shipdate" : "$purchaseorder.shipdate"}}
whereas, find not allow this.
why not aggregate output return dbcursor or list? , why can't count of documents returned?
thank you.
why not aggregate output return dbcursor or list?
the aggregation framework created solve easy problems otherwise require map-reduce.
this framework commonly used compute data requires full db input , few document output.
what difference between $match operator used inside aggregate function , regular find in mongodb?
one of differences, stated, return type. find operations output return dbcursor.
other differences:
- aggregation result must under 16mb. if using shards, full data must collected in single point after first $group or $sort.
- $match purpose improve aggregation's power, has other uses, improve aggregation performance.
and why can't count of documents returned?
you can. count number of elements in resulting array or add following command end of pipe:
{$group: {_id: null, count: {$sum: 1}}}
why doesn't find function allow renaming field names aggregate function?
mongodb young , features still coming. maybe in future version we'll able that. renaming fields more critical in aggregation in find.
edit (2014/02/26):
mongodb 2.6 aggregation operations return cursor.
Comments
Post a Comment