Mongodb中几种聚合查询组合的案例
来源:互联网 发布:sqlserver未安装 编辑:程序博客网 时间:2024/05/29 11:11
db.onePager2ReadHistory.aggregate([ {$match: {'userId': '55054a56ad274f0b473fad39', 'isDeleted': 0}}, {$unwind: '$articleTags'}, { $group: { '_id': {'tagName': '$userId'}, 'firstTimeReadingPoints': { $sum: { $cond: [ '$isLongTimeReading', 4, { $cond: [ {$gt: ['$readCount', 0]}, 3, 0 ] } ] } }, 'praisePoints': { $sum: { $cond: [ {$eq: ['$like', 1]}, 3, 0 ] } }, 'repeatReadingPoints': { $sum: { $cond: [ {$gt: ['$readCount', 1]}, { $multiply: [ 6, { $subtract: ['$readCount', 1] } ] }, 0 ] } } } }, { $project: { '_id': 0, 'tagName': '$_id.tagName', 'firstTimeReadingPoints': 1, 'praisePoints': 1, 'repeatReadingPoints': 1, 'weight': { $divide: [ {$add: ['$firstTimeReadingPoints', '$praisePoints', '$repeatReadingPoints']}, 10 ] } } }])
阅读全文
0 0
- Mongodb中几种聚合查询组合的案例
- MongoDB的聚合查询
- MongoDB 高级聚合查询
- mongodb nodeJs聚合查询
- MongoDB 聚合查询
- mongodb mapreduce 聚合查询
- MongoDB聚合查询
- java MongoDB 聚合查询aggregation
- MongoDB查询、索引和聚合
- MongoDB Spring实现(聚合查询)
- MongoDB高级查询[聚合Group]
- MongoDB高级查询[聚合Group]
- MongoDB高级查询[聚合Group]
- mongodb 聚合查询每天统计
- mongodb的聚合查询(分组统计、排序)
- 二、MongoDB的高级查询(聚合、游标、管道、索引)
- MongoDB的聚合查询(两种方式)
- Java中使用mongodb的aggregate聚合查询
- if else 与 switch case的区别:
- Hadoop2.7.2高可用(HA)环境下Hbase高可用(HA)环境的搭建(在Ubuntu14.04下以root用户进行配置)
- 五种开源协议 (GPL,LGPL,BSD,MIT,Apache) 比较
- 【转】linux下kill进程的N种方法
- 运算符
- Mongodb中几种聚合查询组合的案例
- 30天自制操作系统------保护操作系统
- Linux上安装GCC(C和C++编译器)
- Java并发理论知识框架总结
- 一位ACMer过来人的心得
- Java常用集合总结笔记
- Android 6.0打开串口返回-1问题
- java对象的强引用,软引用,弱引用和虚引用
- 百度网盘文件自动分类sql 并带有对应标识图标