So I have data which has null or no document for certain data points. Here is some set of commands demonstrating data
db.perfR.find({platform:"mac", "filename" : "f1.json"},{filename:1, platform:1, int_secs:1, version:1, _id:0})
{ "filename" : "f1.json", "platform" : "mac", "version" : "1.4.14", "int_secs" : 15 }
Indicates only one entry for "Mac"
db.perfR.find({platform:"win", "filename" : "f1.json"},{filename:1, platform:1, int_secs:1, version:1, _id:0}).count()
0
Indicates no entry for Win
Here is the aggregation command
db.perfR.aggregate([ {$sort:{version: -1 }},{ $group:{ _id: {platform:"win", "filename" : "f1.json", version:"$version"}, avgSecs: {$avg:"$int_secs"} } }])
And output
{ "_id" : { "platform" : "win", "filename" : "f1.json", "version" : "1.4.13" }, "avgSecs" : 759 }
{ "_id" : { "platform" : "win", "filename" : "f1.json", "version" : "1.4.14" }, "avgSecs" : 415.46153846153845 }
{ "_id" : { "platform" : "win", "filename" : "f1.json", "version" : "3.0.0_dev" }, "avgSecs" : 563.8333333333334 }
I am quiet confused where does Mongodb get all that data from and how to restrict it to look for values that are present.
Note: There are other entries for other versions, which I have not shown here for brevity.
Any pointers to improve the aggregation command would be useful