I have been looking around and searching the internet, but I couldn't find an answer. Maybe I am wrong with my aggregation, please correct me if I am wrong.
supposedly I have a data like this
mongos> db.data_analytics.find().sort({_id:-1}).limit(1).pretty()
{
"title" : "data weather currency",
"time" : "Sun Dec 08 2013 04:01:51 GMT+0900 (JST)",
"_id" : ObjectId("52a3709f52d744c201000ba6"),
"dataAnalytics" : [
{
"keyItem" : "currency-yen-php",
"currency" : 0.427044,
"from" : "JPY",
"to" : "PHP",
"time" : "Sun Dec 08 2013 04:01:49 GMT+0900 (JST)",
"key" : "currency"
},
{
"keyItem" : "weather-akiruno",
"main-temp" : "5.78",
"main-temp_min" : "2.78",
"main-temp_max" : "7.78",
"weather-main" : "Clouds",
"weather-description" : "scattered clouds",
"time" : "Sun Dec 08 2013 04:01:50 GMT+0900 (JST)",
"key" : "weather"
},
],
"__v" : 0
}
I want to group and count by "$dataAnalytics.currency", but I get an error in a Sharded environment like this
mongos> db.data_analytics.aggregate([{$unwind: "$dataAnalytics"}, {$group:{_id:"$dataAnalytics.currency", c: {$sum:1}}}])
{
"code" : 16390,
"ok" : 0,
"errmsg" : "exception: sharded pipeline failed on shard jeanepaul_set_pi_debian_01: { errmsg: \"exception: invalid operator \"$const\"\", code: 15999, ok: 0.0 }"
}
I have tried doing this in replica set successfully, but no luck in sharded environment. what could be the problem?
I appreciate any help, and thank you for any help in advance!