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
)
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}}
]
)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.