[SERVER-5349] map-reduce ignores 'value' key when outType is REDUCE Created: 21/Mar/12  Updated: 06/Dec/22  Resolved: 16/Aug/19

Status: Closed
Project: Core Server
Component/s: MapReduce
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Minor - P4
Reporter: Kyle Banker Assignee: Backlog - Query Team (Inactive)
Resolution: Done Votes: 1
Labels: query-44-grooming
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
Assigned Teams:
Query
Operating System: ALL
Participants:

 Description   

Here's a test case from a user:
https://gist.github.com/2152039

The REDUCE outType appears to reduce against the second key in the existing document rather than reducing against the value key.



 Comments   
Comment by David Storch [ 16/Aug/19 ]

This issue no longer reproduces on the master branch:

MongoDB Enterprise > db.f.mapReduce(m, r, {out: 'agg'})
{
	"result" : "agg",
	"timeMillis" : 185,
	"counts" : {
		"input" : 4,
		"emit" : 4,
		"reduce" : 2,
		"output" : 2
	},
	"ok" : 1
}
MongoDB Enterprise > db.agg.find()
{ "_id" : 1, "value" : 7 }
{ "_id" : 2, "value" : 12 }
MongoDB Enterprise > db.agg.update({_id: 1}, {$set: {a: 100}})
WriteResult({ "nMatched" : 1, "nUpserted" : 0, "nModified" : 1 })
MongoDB Enterprise >  db.agg.find()
{ "_id" : 1, "value" : 7, "a" : 100 }
{ "_id" : 2, "value" : 12 }
MongoDB Enterprise >  db.f.mapReduce(m, r, {out: {reduce: 'agg'}})
{
	"result" : "agg",
	"timeMillis" : 173,
	"counts" : {
		"input" : 4,
		"emit" : 4,
		"reduce" : 2,
		"output" : 2
	},
	"ok" : 1
}
MongoDB Enterprise > db.agg.find()
{ "_id" : 1, "value" : 14 }
{ "_id" : 2, "value" : 24 }

I'm closing it as "Gone Away".

Generated at Thu Feb 08 03:08:37 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.