xinghe0 发表于 2015-12-22 14:37:06

MongoDB - MapReduce 实战

map = function() { emit(this.school_number, this.ticket_number) };

reduce = function(key, value){ return Array.sum(',' + value).slice(1); };

db.tickets.mapReduce(map, reduce, {out: {inline:1}})

db.tickets.mapReduce(map, reduce, {out: {inline:1}, query: {"school_bucket": "1"}})

db.tickets.mapReduce(map, reduce, {out: {inline:1}, query: {"school_number": "2719"}})

db.tickets.mapReduce(map, reduce, “output”)

db.output.find()
页: [1]
查看完整版本: MongoDB - MapReduce 实战