如果mongo聚合结果为:
{
_id : "5c1a39d182ceb728c3430275",
docs : {
"First Name": "Nilesh",
"Last Name" : "Sodha",
"Age" : 23
}
},
{
_id : "5c1a39d182ceb728c3430274",
docs : {
"First Name": "Pradip",
"Last Name" : "Sodha",
"Age" : 25
}
}
如何在JAVA中基于“年龄”获得排序结果
答案 0 :(得分:1)
尝试一下
mongoTemplate.find(new Query(Criteria.where("_id").is(mongoId))
.with(new Sort(Sort.Direction.DESC, "Age")), eClass);
mongoId =自动生成的mongo id