We should use the aggregation method provided by MongoDB, and here is the link: docs.mongodb.org/manual/applications/aggregation .
In my case, I use this query in MongoDB Input of Kettle, and we also need to select Query - this is pipline aggregation.
{$match: {activity_type: " view "}}, {$sort: {activity_target: -1 } }, {$limit: 10}
The following screen shots will help you understand operations more clearly.


source share