I have something like:
mongoTemplate.mapReduce("myCollection", MAP_FUNC, REDUCE_FUNC, KeyValuePair.class);
Then the result looks like:
[
{id: "1", count: 5},
{id: "2", count: 20},
{id: "3", count: 9},
{id: "4", count: 3}
]
How can I sort this array like:
[
{id: "2", count: 20},
{id: "3", count: 9},
{id: "1", count: 5},
{id: "4", count: 3}
]
and after that limit result to 5.
There is a sort option in MongoDB mapReduce, but I cannot find it in class org.springframework.data.mongodb.core.mapreduce.MapReduceOptions from Spring Data MongoDB.