I have data in mongodb in following format. i presented below two row of my mongodb data of table named 'feed'.
{
"_id" : ObjectId("55e80a725ae35bbfc6dce074"),
"sourceId" : "12345",
"sourceName" : "MyPage",
"channelId" : "67890",
"channelName" : "Facebook",
"likeCount" : 1,
"feedData" : {
"from" : {
"id" : "416992615172913",
"name" : "Ashish Kumar"
},
"created_time" : "2015-08-04T09:54:39+0000",
},
"sentiment" : "neutral",
}
{
"_id" : ObjectId("55e80a725ae35bbfc6dce074"),
"sourceId" : "23456",
"sourceName" : "YourPage",
"channelId" : "67890",
"channelName" : "Facebook",
"likeCount" : 2,
"feedData" : {
"from" : {
"id" : "416992615172913",
"name" : "Ashish Kumar"
},
"created_time" : "2015-08-04T09:54:39+0000",
},
"sentiment" : "positive",
}
I want to perform groupBy on field feedData.from.id where channelName is equal to 'Facebook', sum of like count, all sources in an array, all sentiment in an array. i want all data associated with feedData.from.id in the format given below using spring mongo.
{
"feedDatafromid" : "416992615172913",
"name" : "Ashish Kumar",
"sourceName" : ["MyPage","YourPage"],
"channel" : "Facebook",
"likeCount" : 3,
"sentiment" : ["neutral","positive"]
}
Can someone help me to write code in java Spring to group the data of mongodb in given manner.