MapReduce
Mapreduce: The set of targets to manipulate
Map : Map function (generate key-value pair sequence as reduce function parameter)//incoming group key and value to be counted
Reduce: Statistical functions//Format the returned Parameter object
Query: Target record filtering//Before MP filter criteria for the query
Sort : Target record sorting
limit: Limits the number of target records
Out : The statistics result holds the collection (does not specify the use temporary collection, after the client disconnects automatically deletes)//outputs the result in a table
keeptemp: Whether to keep temporary collections
Finalize: Final processing function (save result set after final collation of reduce return result)//result processing
Scope: Import external variables to map, reduce, finalize
Verbose: Displays detailed time statistics.
Data structure :
Db.runcommand ({mapreduce: "Students", map:function () {emit (This.classid,this.name);},reduce:function (key,values) { var res={classid:key,names:values} return res;},query:{"age": {"$GT": Ten}}, Finalize:function (key,reducevalues) {var Obj={};obj.keyname=key;obj.values=reducevalues.names;return obj;},out: "TEST_MP2"})
Db.runcommand ({mapreduce: "Students", map:function () {emit (This.classid,this.name);},reduce:function (key,values) { return values.length;},query:{"age": {"$gt": 10}},out: "TEST_MP2"})
For the second statistic step:
Mongodb--mapreduce Distribution Statistics S