Azure Cosmos DB mongo db api: Get count of record for a certain attribute

Priyanka Jain 1 Reputation point
2022-10-04T03:44:20.737+00:00

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 }
}
}
])

Azure Cosmos DB
Azure Cosmos DB
An Azure NoSQL database service for app development.
1,543 questions
{count} votes