map code:
$map = new MongoCode("function(){
emit(333,this);
}");
reduce code:
$reduce = new MongoCode("function(key, values) {
r=0;
for(var idx=0;idx<values.length;idx++){
r+=1;
}
return r;
}");
run code:
$result = $db->command(array(
"mapreduce" => "gameLog",
"map" => $map,
"reduce" => $reduce,
"out" => array("replace" => "gameLogResult")
)
);
the run code return: Array ( [result] => gameLogResult [timeMillis] => 284 [counts] => Array ( [input] => 18864 [emit] => 18864 [reduce] => 189 [output] => 1 )
[ok] => 1
) the map-reduce result is that { "_id" : 333, "value" : 65 },bug i supposed result is that { "_id" : 333, "value" : 18864 } Who can tell me why is this,Help me!