I am a beginner in MongoDB. I have 20 million documents in a MongoDB collection. Example of a single document:
I want to get the total tweet count, friends count and followers count of each user_screen_name along with each user_screen_name's account creation year.
I tried this:
user_details_pipeline = [{
"$project": {
"_id": 0,
"user_mentions": 1,
"user_followers_count": 1,
"user_friends_count": 1,
"user_account_creation": 1
}
}, {
"$unwind": "$user_mentions"
}, {
"$group": {
"_id": "$user_mentions.screen_name",
"count": {
"$sum": 1
}
}
}, {
"$sort": {
"count": -1
}
}
]
But this does not querying the count of tweets, followers, friends and account creation date, only how many times a user is being mentioned. Can anyone please help?
Example of one output:
{"user_screen_name": "BorisJohnson", "user_followers_count": 1000000, "user_friends_count": 50, "total_tweets": 50000, "user_account_creation": 2012}
