mongodb - How to use pre-aggregation? -
i building stats online application. logging every hits mongodb.
like
log = {:user => 'devid',:activity=>'visited home page',:browser=>'chrome-5.3',:ip=>'10.11.35.211',:controller=>'home',:action=>'home_page',:created_at=>'2014-06-02 15:43:00'}
mongo.insert(log)
pre-aggregations controller-action combination
- log.daily.update({_id=>'20140602-home-home_page',:metadata=>{:controller=>'home',:action=>'home_page',date=>isodate("2014-06-02t15:34:23")}},{$inc:{daily.3=>1}},{:upsert=>true})
pre-aggregations user combination
- log.daily.update({_id=>'20140602-devid',:metadata=>{:user_name=>'devid',date=>isodate("2014-06-02t15:34:23")}},{$inc:{daily.3=>1}},{:upsert=>true})
similarly creating monthly , yearly aggregation. gives every hit webpage there total 7 collections need updated (1 need create + 6 need update if exist or create new collections).
my question correct approach built real time analytics ...??
Comments
Post a Comment