-
Type: Bug
-
Resolution: Works as Designed
-
Priority: Major - P3
-
None
-
Affects Version/s: 4.3.6
-
Component/s: MapReduce
-
None
-
Fully Compatible
-
ALL
It seems the 4.4 server no longer returns counts in mapreduce operations.
Following the instructions in https://docs.mongodb.com/manual/reference/command/mapReduce/#out-options, setup as follows:
db.orders.insertMany([ { _id: 1, cust_id: "Ant O. Knee", ord_date: new Date("2020-03-01"), price: 25, items: [ { sku: "oranges", qty: 5, price: 2.5 }, { sku: "apples", qty: 5, price: 2.5 } ], status: "A" }, { _id: 2, cust_id: "Ant O. Knee", ord_date: new Date("2020-03-08"), price: 70, items: [ { sku: "oranges", qty: 8, price: 2.5 }, { sku: "chocolates", qty: 5, price: 10 } ], status: "A" }, { _id: 3, cust_id: "Busby Bee", ord_date: new Date("2020-03-08"), price: 50, items: [ { sku: "oranges", qty: 10, price: 2.5 }, { sku: "pears", qty: 10, price: 2.5 } ], status: "A" }, { _id: 4, cust_id: "Busby Bee", ord_date: new Date("2020-03-18"), price: 25, items: [ { sku: "oranges", qty: 10, price: 2.5 } ], status: "A" }, { _id: 5, cust_id: "Busby Bee", ord_date: new Date("2020-03-19"), price: 50, items: [ { sku: "chocolates", qty: 5, price: 10 } ], status: "A"}, { _id: 6, cust_id: "Cam Elot", ord_date: new Date("2020-03-19"), price: 35, items: [ { sku: "carrots", qty: 10, price: 1.0 }, { sku: "apples", qty: 10, price: 2.5 } ], status: "A" }, { _id: 7, cust_id: "Cam Elot", ord_date: new Date("2020-03-20"), price: 25, items: [ { sku: "oranges", qty: 10, price: 2.5 } ], status: "A" }, { _id: 8, cust_id: "Don Quis", ord_date: new Date("2020-03-20"), price: 75, items: [ { sku: "chocolates", qty: 5, price: 10 }, { sku: "apples", qty: 10, price: 2.5 } ], status: "A" }, { _id: 9, cust_id: "Don Quis", ord_date: new Date("2020-03-20"), price: 55, items: [ { sku: "carrots", qty: 5, price: 1.0 }, { sku: "apples", qty: 10, price: 2.5 }, { sku: "oranges", qty: 10, price: 2.5 } ], status: "A" }, { _id: 10, cust_id: "Don Quis", ord_date: new Date("2020-03-23"), price: 25, items: [ { sku: "oranges", qty: 10, price: 2.5 } ], status: "A" } ]) var mapFunction1 = function() { emit(this.cust_id, this.price); }; var reduceFunction1 = function(keyCustId, valuesPrices) { return Array.sum(valuesPrices); };
Then run:
db.orders.mapReduce(
mapFunction1,
reduceFunction1,
{ out: "map_reduce_example" }
)
db.orders.mapReduce(
mapFunction1,
reduceFunction1,
{ out: {inline: 1} }
)
4.2 result:
MongoDB Enterprise ruby-driver-rs:PRIMARY> db.orders.mapReduce( ... mapFunction1, ... reduceFunction1, ... { out: "map_reduce_example" } ... ) { "result" : "map_reduce_example", "timeMillis" : 29, "counts" : { "input" : 10, "emit" : 10, "reduce" : 4, "output" : 4 }, "ok" : 1, "$clusterTime" : { "clusterTime" : Timestamp(1589906220, 7), "signature" : { "hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="), "keyId" : NumberLong(0) } }, "operationTime" : Timestamp(1589906220, 7) } MongoDB Enterprise ruby-driver-rs:PRIMARY> MongoDB Enterprise ruby-driver-rs:PRIMARY> MongoDB Enterprise ruby-driver-rs:PRIMARY> db.orders.mapReduce( ... mapFunction1, ... reduceFunction1, ... { out: {inline: 1} } ... ) { "results" : [ { "_id" : "Ant O. Knee", "value" : 95 }, { "_id" : "Busby Bee", "value" : 125 }, { "_id" : "Cam Elot", "value" : 60 }, { "_id" : "Don Quis", "value" : 155 } ], "timeMillis" : 14, "counts" : { "input" : 10, "emit" : 10, "reduce" : 4, "output" : 4 }, "ok" : 1, "$clusterTime" : { "clusterTime" : Timestamp(1589906220, 7), "signature" : { "hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="), "keyId" : NumberLong(0) } }, "operationTime" : Timestamp(1589906220, 7) } MongoDB Enterprise ruby-driver-rs:PRIMARY> MongoDB Enterprise ruby-driver-rs:PRIMARY> MongoDB Enterprise ruby-driver-rs:PRIMARY>
4.4 result:
MongoDB Enterprise ruby-driver-rs:PRIMARY> db.orders.mapReduce( ... mapFunction1, ... reduceFunction1, ... { out: "map_reduce_example" } ... ) { "result" : "map_reduce_example", "ok" : 1, "$clusterTime" : { "clusterTime" : Timestamp(1589906282, 6), "signature" : { "hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="), "keyId" : NumberLong(0) } }, "operationTime" : Timestamp(1589906282, 6) } MongoDB Enterprise ruby-driver-rs:PRIMARY> MongoDB Enterprise ruby-driver-rs:PRIMARY> MongoDB Enterprise ruby-driver-rs:PRIMARY> MongoDB Enterprise ruby-driver-rs:PRIMARY> MongoDB Enterprise ruby-driver-rs:PRIMARY> db.orders.mapReduce( ... mapFunction1, ... reduceFunction1, ... { out: {inline: 1} } ... ) { "results" : [ { "_id" : "Cam Elot", "value" : 60 }, { "_id" : "Ant O. Knee", "value" : 95 }, { "_id" : "Don Quis", "value" : 155 }, { "_id" : "Busby Bee", "value" : 125 } ], "ok" : 1, "$clusterTime" : { "clusterTime" : Timestamp(1589906282, 6), "signature" : { "hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="), "keyId" : NumberLong(0) } }, "operationTime" : Timestamp(1589906282, 6) } MongoDB Enterprise ruby-driver-rs:PRIMARY>
Neither collection nor inline output appear to be producing the counts.
I searched jira for "map reduce counts" and "mapreduce counts" and couldn't locate any tickets where this output would've been intentionally removed.
- related to
-
MONGOID-4848 Add server 4.4 configurations to evergreen
- Closed