我正在尝试聚合事件字段。我应该找到这笔钱。
以下是数据集的示例。
{ "_id" : ObjectId("582db9b82de1b251ee2d60a9"), "uuid" : "4898009f81a3ee8a", "session_id" : "26102016181211", "project_token" : "5a26b01e-622d-4512-aba4-158651cd0846", "starttime" : ISODate("2016-10-26T23:46:07Z"), "activity_name" : "ProductInfoActivity", "content_id" : 987560, "endtime" : ISODate("2016-10-26T23:48:42Z"), "time_duration" : 86245, "motion" : "running", "timestamp" : "Wed Nov 16 11:44:54 +05:30 2016", "os" : "Android", "events" : [ { "Virality" : 3, "_id" : "Virality" } ] }
到目前为止,我已经接受了这个问题。
db.pageview.aggregate([{$match:{'project_token':"5a26b01e-622d-4512-aba4-158651cd0846",'content_id':987560}},{'$group':{ _id : '$events._id','total_Virality':{$sum:'$events.Virality'}}}])
它给我一个结果
{ "_id" : [ "Virality" ], "total_Virality" : 0 }
{ "_id" : null, "total_Virality" : 0 }
它应该给我一个3,但它返回0。
感谢任何帮助。