Created
March 5, 2020 14:04
-
-
Save alfredfrancis/1d6ff8fc333e771520d5664d31dfffde to your computer and use it in GitHub Desktop.
Wordcloud using mongodb data
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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