В настоящее время я работаю над приложением весенней загрузки с MongoDB, и у меня возникли некоторые проблемы, потому что я еще начинаю использовать функции агрегирования с Spring
Вот мои данные:
[
{
"idGroupe": "5e186401219f320c77715eb9",
"groupName": "grp1",
"profilTwitters_ids": [
{
"idProfil": "5ded2abae1692808b799b239",
"tweets": [
{
"idTweet": "5ded2dffe1692808b799b241",
"datePublication": "2019-12-08T16:58:59.702+0000",
"hashtags": [
{
"idHashtag": "5ded2c64e1692808b799b23c",
"label": "recipes "
},
{
"idHashtag": "5ded2c71e1692808b799b23d",
"label": "delicious "
},
{
"idHashtag": "5ded2c7ce1692808b799b23e",
"label": "foodrecipes"
},
{
"idHashtag": "5ded2c84e1692808b799b23f",
"label": "canada "
},
{
"idHashtag": "5ded2c8de1692808b799b240",
"label": "Usa"
},
{
"idHashtag": "5dee65d7e39e962d44a31c40",
"label": "food"
},
{
"idHashtag": "5dee65c8e39e962d44a31c3f",
"label": "cooking"
}
],
"profileOwner": null
},
{
"idTweet": "5dee97c7e87f7447c55faff7",
"datePublication": "2019-12-09T18:51:51.688+0000",
"hashtags": [
{
"idHashtag": "5ded2c64e1692808b799b23c",
"label": "recipes "
},
{
"idHashtag": "5ded2c71e1692808b799b23d",
"label": "delicious "
},
{
"idHashtag": "5ded2c7ce1692808b799b23e",
"label": "foodrecipes"
},
{
"idHashtag": "5ded2c84e1692808b799b23f",
"label": "canada "
},
{
"idHashtag": "5ded2c8de1692808b799b240",
"label": "Usa"
},
{
"idHashtag": "5dee65d7e39e962d44a31c40",
"label": "food"
},
{
"idHashtag": "5dee65c8e39e962d44a31c3f",
"label": "cooking"
}
],
"profileOwner": null
},
{
"idTweet": "5dee97d9e87f7447c55faff8",
"datePublication": "2019-12-09T18:52:09.255+0000",
"hashtags": [
{
"idHashtag": "5ded2c64e1692808b799b23c",
"label": "recipes "
},
{
"idHashtag": "5ded2c71e1692808b799b23d",
"label": "delicious "
},
{
"idHashtag": "5ded2c7ce1692808b799b23e",
"label": "foodrecipes"
},
{
"idHashtag": "5ded2c84e1692808b799b23f",
"label": "canada "
},
{
"idHashtag": "5ded2c8de1692808b799b240",
"label": "Usa"
},
{
"idHashtag": "5dee65d7e39e962d44a31c40",
"label": "food"
},
{
"idHashtag": "5dee65c8e39e962d44a31c3f",
"label": "cooking"
}
],
"profileOwner": null
},
{
"idTweet": "5dee97dae87f7447c55faff9",
"datePublication": "2019-12-09T18:52:10.358+0000",
"hashtags": [
{
"idHashtag": "5ded2c64e1692808b799b23c",
"label": "recipes "
},
{
"idHashtag": "5ded2c71e1692808b799b23d",
"label": "delicious "
},
{
"idHashtag": "5ded2c7ce1692808b799b23e",
"label": "foodrecipes"
},
{
"idHashtag": "5ded2c84e1692808b799b23f",
"label": "canada "
},
{
"idHashtag": "5ded2c8de1692808b799b240",
"label": "Usa"
},
{
"idHashtag": "5dee65d7e39e962d44a31c40",
"label": "food"
},
{
"idHashtag": "5dee65c8e39e962d44a31c3f",
"label": "cooking"
}
],
"profileOwner": null
},
{
"idTweet": "5dee97dbe87f7447c55faffa",
"datePublication": "2019-12-09T18:52:11.370+0000",
"hashtags": [
{
"idHashtag": "5ded2c64e1692808b799b23c",
"label": "recipes "
},
{
"idHashtag": "5ded2c71e1692808b799b23d",
"label": "delicious "
},
{
"idHashtag": "5ded2c7ce1692808b799b23e",
"label": "foodrecipes"
},
{
"idHashtag": "5ded2c84e1692808b799b23f",
"label": "canada "
},
{
"idHashtag": "5ded2c8de1692808b799b240",
"label": "Usa"
},
{
"idHashtag": "5dee65d7e39e962d44a31c40",
"label": "food"
},
{
"idHashtag": "5dee65c8e39e962d44a31c3f",
"label": "cooking"
}
],
"profileOwner": null
},
{
"idTweet": "5dee97dce87f7447c55faffb",
"datePublication": "2019-12-09T18:52:12.265+0000",
"hashtags": [
{
"idHashtag": "5ded2c64e1692808b799b23c",
"label": "recipes "
},
{
"idHashtag": "5ded2c71e1692808b799b23d",
"label": "delicious "
},
{
"idHashtag": "5ded2c7ce1692808b799b23e",
"label": "foodrecipes"
},
{
"idHashtag": "5ded2c84e1692808b799b23f",
"label": "canada "
},
{
"idHashtag": "5ded2c8de1692808b799b240",
"label": "Usa"
},
{
"idHashtag": "5dee65d7e39e962d44a31c40",
"label": "food"
},
{
"idHashtag": "5dee65c8e39e962d44a31c3f",
"label": "cooking"
}
],
"profileOwner": null
}
],
"profileOwner": "5ded2a5de1692808b799b238",
"groups_ids": null
},
{
"idProfil": "5dee9e29f58af643b3ee27a3",
"tweets": [
{
"idTweet": "5deea590f58af643b3ee27c3",
"datePublication": "2019-12-09T19:50:40.841+0000",
"hashtags": [
{
"idHashtag": "5dee9f8ef58af643b3ee27a8",
"label": "Solutionneurs"
},
{
"idHashtag": "5dee9f9df58af643b3ee27a9",
"label": "Team237"
},
{
"idHashtag": "5dee9fbff58af643b3ee27aa",
"label": "Cmr"
}
],
"profileOwner": null
},
{
"idTweet": "5deea5a9f58af643b3ee27c4",
"datePublication": "2019-12-09T19:51:05.760+0000",
"hashtags": [
{
"idHashtag": "5dee9f8ef58af643b3ee27a8",
"label": "Solutionneurs"
},
{
"idHashtag": "5dee9f9df58af643b3ee27a9",
"label": "Team237"
},
{
"idHashtag": "5dee9fbff58af643b3ee27aa",
"label": "Cmr"
}
],
"profileOwner": null
},
{
"idTweet": "5deea5aaf58af643b3ee27c5",
"datePublication": "2019-12-09T19:51:06.355+0000",
"hashtags": [
{
"idHashtag": "5dee9f8ef58af643b3ee27a8",
"label": "Solutionneurs"
},
{
"idHashtag": "5dee9f9df58af643b3ee27a9",
"label": "Team237"
},
{
"idHashtag": "5dee9fbff58af643b3ee27aa",
"label": "Cmr"
}
],
"profileOwner": null
},
{
"idTweet": "5deea5abf58af643b3ee27c6",
"datePublication": "2019-12-09T19:51:07.284+0000",
"hashtags": [
{
"idHashtag": "5dee9f8ef58af643b3ee27a8",
"label": "Solutionneurs"
},
{
"idHashtag": "5dee9f9df58af643b3ee27a9",
"label": "Team237"
},
{
"idHashtag": "5dee9fbff58af643b3ee27aa",
"label": "Cmr"
}
],
"profileOwner": null
},
{
"idTweet": "5deea5acf58af643b3ee27c7",
"datePublication": "2019-12-09T19:51:08.772+0000",
"hashtags": [
{
"idHashtag": "5dee9f8ef58af643b3ee27a8",
"label": "Solutionneurs"
},
{
"idHashtag": "5dee9f9df58af643b3ee27a9",
"label": "Team237"
},
{
"idHashtag": "5dee9fbff58af643b3ee27aa",
"label": "Cmr"
}
],
"profileOwner": null
}
],
"profileOwner": "5dee9e59f58af643b3ee27a4",
"groups_ids": null
}
]
}
]
Я пытался получить список хэштегов и idProfil, используя эту функцию:
public List<ResultHashtags> GetRecommendedHashtags(String idGroupe) {
MatchOperation matchOperation=getMatchOperation(idGroupe);
ProjectionOperation projectOperation = project("$profilTwitters_ids.tweets.hashtags");
AggregationResults<ResultHashtags> result =
PMongoTemp.aggregate(Aggregation.newAggregation(matchOperation,projectOperation),
Groupe.class, ResultHashtags.class);
return result.getMappedResults();
}
и это класс данных ответа:
package com.pds.sys_recommendation.entities;
import java.util.List;
public class ResultHashtags {
private List<Hashtag> tweets;
public List<Hashtag> getTweets() {
return tweets;
}
public void setTweets(List<Hashtag> tweets) {
this.tweets = tweets;
}
}