输入:我有数百个事件源,这些事件源生成事件,每个事件存储在MongoDB中的方式为:
{
eventSourceName: "LondonDC"
score: 0.4
timestamp: 16745735746
},
{
eventSourceName: "LondonDC"
score: 0.5
timestamp: 16745745746
},
{
eventSourceName: "DublinDC"
score: 0.8
timestamp: 16745765746
}
score
字段会不时变化,并且我想绘制按得分排序的前20个事件源的score
字段的时间序列折线图(因此,我将看到前20名表演者)
我尝试使用unwind
,但没有帮助:
[
{ "$unwind": "$data" },
{
"$lookup": {
"from": "data",
"localField": "data",
"foreignField": "_id",
"as": "resultingArray"
}
},
{ "$unwind": "$resultingArray" },
{
"$group": {
"_id": "$name",
"data": { "$push": "$resultingArray" }
}
}
]