我试图用查询过滤mapReduce命令.mapReduce命令似乎没有使用此查询.当我使用具有相同参数的runCommand时,将使用查询过滤器.我尝试使用mongodb 2.2.1和2.0.1.
我没有使用mapReduce函数的查询.
m = function () {
if (this.duration > 0) {
emit("dur", this.duration);
}
}
r = function (key, values) {
var index = 0;
var sum = 0;
for (var i = 0; i < values.length; i++) {
sum += values[i];
index++;
}
return sum / index;
}
Run Code Online (Sandbox Code Playgroud)
此命令不起作用:
res = db.movies.mapReduce(m,r, {out: { inline : 1}},{query:{kinds:'Action'}});
{
"results" : [
{
"_id" : "dur",
"value" : 5148.227224559308
}
],
"timeMillis" : 1849,
"counts" : {
"input" …Run Code Online (Sandbox Code Playgroud)