How to Group mongodb - mapReduce output?

后端 未结 3 738
余生分开走
余生分开走 2020-12-11 22:19

i have a query regarding the mapReduce framework in mongodb, so i have a result of key value pair from mapReduce function , now i want to run the query on this output of map

3条回答
  •  北荒
    北荒 (楼主)
    2020-12-11 23:14

    You could try to group the output data after mapreduce to every 5 interval count through aggregate like below

    db.data.aggregate([
        { "$group": {
            "_id": {
                "$subtract": [
                    { "$subtract": [ "$value.count", 0 ] },
                    { "$mod": [ 
                        { "$subtract": [ "$value.count", 0 ] },
                        5
                    ]}
                ]
            },
            "count": { "$sum": 1 }
        }}
    ])
    

    Also maybe here is one related question here.

提交回复
热议问题