Azure Cosmos DB mongo db api: Get count of record for a certain attribute
Priyanka Jain
1
Reputation point
I am trying to get count of records coloumn wise. for approx 266k record its taking 32K. We are using aggregate operation. Is there any possible solution to reduce the number of RU's
db.getCollection('Product').aggregate( [
{
$match: {
$and: [
{ "productPrice": {$lte:"20" } },
{ "productPrice": { $gte: "21" } }
] }
},
{
"$group": {_id: { productPrice: "$productPrice" },
{count: { $sum: 1 }
}
}
])