MongoDB客戶端:
1,NoSQL Manager for MongoDB
2,Robomongo(推薦,好多教程上的語句能夠直接使用)
不一樣的客戶端執行語句有差別
參考:https://docs.mongodb.com/manual/reference/operator/aggregation/count/web
一,NoSQL Manager for MongoDB客戶端語句mongodb
1,id查詢使用ObjectIdcookie
2,時間查詢使用ISODatedom
{ "_id" : ObjectId("5b498fb070bb993b335ab1c0"), "_class" : "com.onloon.custom.data.model.importdata.DetectiveTask", "keywords" : "pear", "status" : 0, "userId" : "645a828883714b679dc5d004e93dc192", "serverLevel" : "1", "createDate" : "20180714", "createTime" : ISODate("2018-07-14T05:52:48.584Z"), "updateTime" : ISODate("2018-07-14T05:52:48.584Z"), "countries" : "Russia&&United Kingdom" }
{"userId":"645a828883714b679dc5d004e93dc192", "_id" : ObjectId("5b498fb070bb993b335ab1c0"),"createTime" : {$gte : ISODate("2018-07-14T05:52:48.584Z")}}
二,Robomongo客戶端url
1,SUMspa
按照productType統計pv的總和:3d
{
"_id" : ObjectId("598bb71370bb9933cf6fa196"),
"_class" : "com.onloon.website.analytics.core.entity.ProductTrafficBean",
"productId" : "83277ed6be2f4e46b6fbdc6866416e94",
"platform" : 0,
"shopId" : "151623511167744942",
"pv" : NumberLong(3),
"uv" : NumberLong(1),
"uvTime" : NumberLong(252186),
"msgProductCount" : 2,
"date" : "2017-08-10",
"productType" : "1",
"cookie" : ""
}code
db.getCollection('doc_product_traffic').aggregate([{$group : {_id : "$productType", num_tutorial : {$sum : "$pv"}}}])
按照pageType統計總數:orm
{
"_id" : ObjectId("5a7d975c01c56936f40d1f27"),
"_class" : "com.onloon.website.analytics.core.entity.PageDirectBean",
"pageId" : "aa123a",
"pageType" : 2,
"redirectUrl" : "www.baidu.com"
}server
db.getCollection('pageDirectBean').aggregate([{$group : {_id : "$pageType", num_tutorial : {$sum : 1}}}])
2,COUNT
{「_ id」:ObjectId(「54936 ... dd0c」),「last_name」:「smith」,「first_name」:「mike」} {「_ id」:ObjectId(「54936 ... dd0d」),「last_name」:「smith 「,」first_name「:」william「} {」_ id「:ObjectId(」54936 ... dd0e「),」last_name「:」smith「,」first_name「:」william「} {」_ id「:ObjectId(」54936 ... dd0f「),」last_name「:」smith「,」first_name「:」mark「}
> db.collection.find({「last_name」:「smith」}).count();> db.collection.distinct(「first_name」,{「last_name」:「smith」}).length;
獨立站點總IP數:
{ "_id" : ObjectId("595dada070bb99301b45695a"), "_class" : "com.onloon.website.analytics.core.entity.PageViewLogBean", "domain" : "baidu.com", "url" : "dsds", "pageTitle" : "商品詳情", "pageId" : "3232", "cookie" : "aba7981f-332a-421a-8a56-82095ddad5dd", "viewDate" : NumberLong(1499311520843), "viewFrom" : "0", "shopId" : "3232", "ip" : "223.93.170.250", "platform" : 0, "date" : "2017-07-06" } db.getCollection('doc_page_view_log').aggregate([{$match:{viewDate:{$lt:1532016000000}}},{$group: {_id: '$ip'} },{$count:"ipcount"}])
偵探次數:
{ "_id" : ObjectId("5acf4e0170bb9918956ce28d"), "_class" : "com.onloon.custom.data.model.importdata.DetectiveTask", "keywords" : "phone", "status" : 0, "userId" : "83fcb7323c9a47de98403be7cedb9433", "serverLevel" : "1", "createDate" : "20180412", "createTime" : ISODate("2018-04-12T12:16:01.885Z"), "updateTime" : ISODate("2018-04-12T12:16:01.885Z") } db.getCollection('detectiveTask').count({"createTime" : {$lte : ISODate("2018-07-20T00:00:00.584Z")}})