Details
-
Bug
-
Resolution: Done
-
Major - P3
-
None
-
Query
-
Fully Compatible
-
ALL
Description
The keys produced by the mapReduce emit function are always compared using the simple collation rather than the mapReduce operation's collation. For example, consider the following script:
db.c.drop();
|
db.c.insert({_id: 1, str: "foo"});
|
db.c.insert({_id: 2, str: "FOO"});
|
db.c.insert({_id: 3, str: "bar"});
|
db.c.insert({_id: 4, str: "BAR"});
|
|
|
db.c.mapReduce(
|
function() { emit(this.str, 1); },
|
function(key, values) { return Array.sum(values); },
|
{out: {inline: 1}, collation: {locale: "en", strength: 2}}
|
);
|
This script produces output such as the following:
{
|
"results" : [
|
{
|
"_id" : "BAR",
|
"value" : 1
|
},
|
{
|
"_id" : "FOO",
|
"value" : 1
|
},
|
{
|
"_id" : "bar",
|
"value" : 1
|
},
|
{
|
"_id" : "foo",
|
"value" : 1
|
}
|
],
|
"timeMillis" : 133,
|
"counts" : {
|
"input" : 4,
|
"emit" : 4,
|
"reduce" : 0,
|
"output" : 4
|
},
|
"ok" : 1
|
}
|
Since the operation is using the English case-insensitive collation, one might expect the results array to contain 2 elements rather than 4. This is because "FOO" == "foo" and "BAR" == "bar" with respect to the collation.
Attachments
Issue Links
- is related to
-
SERVER-26422 Group command does not group with respect to the collation
-
- Closed
-