We are having an issue writing a map / reduce for the Mongo shell to process web logs. We have it calculating the daily mobile and desktop user hits but when we are trying to reference past documents to calculate a trailing 7 and 30 days of user hits. Any help or advise would be appreciated.
{
"_id" : {
"SiteName" : "All Sites",
"Date" : ISODate("2011-01-18T00:00:00Z")
},
"value" : {
"Day" : {
"AccessTypeTotal" : 9,
"AccessTypeDirect" : 0,
"AccessTypeDirectPerc" : 0,
"AccessTypeSearch" : 8,
"AccessTypeSearchPerc" : 88.88888888888889,
"AccessTypeNavigation" : 1,
"AccessTypeNavigationPerc" : 11.11111111111111
}
}
}
The MongoDB Cookbook has an excellent article that describes this process.
For trailing 30 days use something like this:
Read the full article for a better understanding of how to use this with your documents.