Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Wordcloud using mongodb data
db.getCollection('cogniwidebot').aggregate([
{
"$project": {
"words": { "$split": ["$query", " "] }
}
},
{
"$unwind": {
"path": "$words"
}
},
{
"$group": {
"_id": "$words",
"count": { "$sum": 1 }
}
},
{ "$sort": { "count": -1 } },
{ "$limit": 5 }
])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment