Mongo FastData
Edited-
Top Emotion Aggregation
db.getCollection('tweet_1mdb').aggregate(
{$match: { AnalysisEmotion: { $exists: true } } }, {$project : {AnalysisEmotion:'$AnalysisEmotion.document.AnalysisEmotion',_id:0}}, {$group: {_id: null, anger: { $avg: "$AnalysisEmotion.anger" }, disgust: { $avg: "$AnalysisEmotion.disgust" }, fear: { $avg: "$AnalysisEmotion.fear" }, joy: { $avg: "$AnalysisEmotion.joy" }, sadness: { $avg: "$AnalysisEmotion.sadness" }, }}
)
//refactor
db.getCollection('tweet_1mdb').aggregate( {$match: { AnalysisEmotion: { $exists: true } } }, {$project : {AnalysisEmotion:'$AnalysisEmotion.document.AnalysisEmotion',_id:0}}, {$group: {_id: null, anger: { $avg: "$AnalysisEmotion.anger" },disgust: { $avg: "$AnalysisEmotion.disgust" },fear: { $avg: "$AnalysisEmotion.fear" },joy: { $avg: "$AnalysisEmotion.joy" },sadness: { $avg: "$AnalysisEmotion.sadness" },}} )
-
Top Emotion
db.getCollection('tweet_1mdb').aggregate( {$match: { AnalysisSentiment: { $exists: true } } }, {$project: { score:'$AnalysisSentiment.document.score', sentiment:{ $switch: { branches: [ { case: { $gt : [ "$AnalysisSentiment.document.score" , 0 ] }, then: "Positive" }, { case: { $lt : [ "$AnalysisSentiment.document.score" , 0 ] }, then: "Negative" } ], default: "Neutral" } } } }, {$group : {'_id': {'sentiment': '$sentiment',},count:{$sum:1}}}, {$project: {sentiment: '$_id.sentiment',count:1 }} )
db.getCollection('tweet_1mdb').aggregate( {$match: { AnalysisSentiment: { $exists: true } } }, {$project:{score:'$AnalysisSentiment.document.score',sentiment:{$switch:{branches: [{case: { $gt : [ "$AnalysisSentiment.document.score" , 0 ] },then: "Positive"},{case: { $lt : [ "$AnalysisSentiment.document.score", 0 ] },then: "Negative"}],default: "Neutral"}}}}, {$group : {'_id': {'sentiment': '$sentiment',},count:{$sum:1}}}, {$project: {sentiment: '$_id.sentiment',count:1 }} )
-
Hashtag Aggregation
db.getCollection('tweet_1mdb').aggregate( { $match: { aylienHashtags: { $exists: true } } }, { $project : { hashtags:'$aylienHashtags.hashtags.hashtags',_id:0}}, { $unwind : '$hashtags' }, { $group: { _id: { 'text':'$hashtags'}, count:{$sum:1} }}, { $project : { text:'$_id.text',count:1, _id:0}}, { $sort: {count:-1}}, { $limit:50} )