mongodb 字符串 截取_Mongodb split字符串后分组统计
生活随笔
收集整理的這篇文章主要介紹了
mongodb 字符串 截取_Mongodb split字符串后分组统计
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
db.getCollection(‘Information’).aggregate([{ $project : { birth : { $split: [“$birthday”, “-“] } } }, {$unwind:”$birth”}, {$match:{birth:/[0-9]{4}/}},{$group : {_id : “$birth”, num : {$sum : 1}}},{$sort:{_id:1}}])
輸出結果:
/* 1 */
{
“_id” : “1996”,
“num” : 104.0
}
/* 2 */
{
“_id” : “1997”,
“num” : 118.0
}
原始數(shù)據(jù)格式:
{
“_id” : “6478413887”,
“crawl_time” : 1576841589,
“nick_name” : “12小時檸檬6478413887”,
“gender” : “男”,
“province” : “山東”,
“city” : “濟南”,
“birthday” : “1979-06-13”,
“vip_level” : “未開通”,
“tweets_num” : 1,
“follows_num” : 344,
“fans_num” : 4
}
總結
以上是生活随笔為你收集整理的mongodb 字符串 截取_Mongodb split字符串后分组统计的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Alt+数字键所能打出的符号表
- 下一篇: Oracle中RowNum的用法