我如何在mongos group功能中指定mongos mapreduce中的条件.
我的数据就像
{lid:1000, age:23}, {lid:3000, age:23}, {lid:1000, age:24}.
Run Code Online (Sandbox Code Playgroud)
我想只发出值为1000的盖子emit(this.lid, this.age).但这会发出所有价值.我想在这里有一个条件.地图中是否有任何减少方法?我试图在reduce函数中使用if条件进行过滤,但它不起作用
您可以在query参数中执行此操作.从文档页面:http://www.mongodb.org/display/DOCS/MapReduce#MapReduce-Overview
db.runCommand(
{ mapreduce : <collection>,
map : <mapfunction>,
reduce : <reducefunction>
--> [, query : <query filter object>] <--
[, sort : <sorts the input objects using this key. Useful for optimization, like sorting by the emit key for fewer reduces>]
[, limit : <number of objects to return from collection>]
[, out : <see output options below>]
[, keeptemp: <true|false>]
[, finalize : <finalizefunction>]
[, scope : <object where fields go into javascript global scope >]
[, verbose : true]
}
);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2320 次 |
| 最近记录: |