Reputation: 63
Unfortunately $sortbycount within an aggregate pipeline is currently not support on Microsoft Azure implementation of MongoDB (CosmosDB). How can I model an easy $sortbycount without actually using it but getting the same results ?
db.gcfblikes.aggregate(
...here are some statements then
{$sortByCount: "$likes.name"}
...more statements
)
Upvotes: 1
Views: 181
Reputation: 12817
try this aggregation pipeline, $sortByCount
is simplified form of $group
and $sort
by count in descending order
db.gcfblikes.aggregate(
[
{$group : {_id : "$likes.name", count : {$sum : 1}}},
{$sort : {count : -1}}
]
)
Upvotes: 3