0
我有一組文檔(帖子),它們在每篇文章中提到了一組用戶。Aggregate array occourances
{
"title": "Some post title",
[ ... ]
"mentions": ["johnsmith", "johndoe", "paul"]
}
我想彙總唯一提及的列表以及它們在所有帖子中提及的次數。例如:
[{ user: "johnsmith", count: 5 }, { user: "benlewis", count: 9 }, { user: "johndoe", count: 1 }]
隨着蒙戈,我會做一些事情,如:
"mentions": [{
"$unwind": "$mentions"
}, {
"$group": {
"_id": "$mentions",
"count": { "$sum": 1 }
}
}]
什麼是相當於Elasticsearch?