[DOCS-1753] map-reduce output result that is less than i supposed Created: 29/Jul/13  Updated: 03/Nov/17  Resolved: 29/Jul/13

Status: Closed
Project: Documentation
Component/s: None
Affects Version/s: None
Fix Version/s: 01112017-cleanup

Type: Improvement Priority: Major - P3
Reporter: auto Assignee: Unassigned
Resolution: Incomplete Votes: 0
Labels: collector-298ba4e7
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Location: http://docs.mongodb.org/manual/core/map-reduce/
User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:22.0) Gecko/20100101 Firefox/22.0
Referrer: http://www.google.com.hk/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&cad=rja&ved=0CCkQFjAA&url=%68%74%74%70%3a%2f%2f%64%6f%63%73%2e%6d%6f%6e%67%6f%64%62%2e%6f%72%67%2f%6d%61%6e%75%61%6c%2f%63%6f%72%65%2f%6d%61%70%2d%72%65%64%75%63%65&ei=MdX1UdGJHc_slAXX_oBI&usg=AFQjCNFvYG3WsDBrSAwvBuVELAtyaCBGug&sig2=ZWBcbwZlMoVHiqtO19l4iw&bvm=bv.49784469,d.dGI
Screen Resolution: 1366 x 768
repo: docs
source: core/map-reduce


Participants:
Days since reply: 10 years, 29 weeks, 2 days ago

 Description   

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 }

,but i supposed result is that

{ "_id" : 333, "value" : 18864 }

Who can tell me why is this,Help me!



 Comments   
Comment by Scott Hernandez (Inactive) [ 29/Jul/13 ]

This project is for documentation improvements and errors.

Please ask questions like this on the mongodb-user group here (http://groups.google.com/group/mongodb-user).

Generated at Thu Feb 08 07:41:49 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.