I am looking for a way to get the top two (or any other) numbers of a specific element from a given collection.
{"id": "xyz" , "fruits": ["Apple", "Mango"]} {"id": "abx", "fruits": ["Apple", "Banana"]} {"id" : "pqr", "fruits": ["Apple", "Mango"]}
In the above example, the result would be: Apple and Mango , since the appearance of Apple (three times) is higher, and then Mango (two times). Do I need to use the Mongo map-reduce functions?
I am more inclined towards the performance and stability of the backend platform. How can I move forward if the "number of cases" occurs in real time?
Any help would be noticeable.
source share