Skip to content

Big Data Analysis

Jaewook Byun edited this page Jul 9, 2015 · 1 revision

MongoDB Map Reduce

MongoDB supports Map-Reduce itself, thus enabling to summarize or analyze your bulk data. This functionality allows you to get results directly or keep results in another collection. For details, refer to MongoDB Map-Reduce

Example: Extension field sampling

This example retrieves one extended data within 1 day of each one EPC, and keep the results in "Summary" collection.

// Prepare mapFunc and reduceFunc
var mapFunc = function(){
    if( this.extension != null ) {
        emit( this.epcList[0].epc + "|" + Math.round(this.eventTime/86400000)*86400000, this.extension.extension.any);
    }
}
var reduceFunc = function( key, values ) {
    return values[0];
}

###Run Map-Reduce### db.ObjectEvent.mapReduce( mapFunc, reduceFunc, {out: "Summary" } )