I have 5 mongo db aggregator queries. Each query has same group part but different match criteria. forexample :
1- count records by email
2- count records by phone
3- count records by xxx...
db.getCollection("myCol").aggregate([
{
"$match": {
{ "contact.email": "[email protected]" }
//.. some more conditions
}
}
{
"$group": {
"_id": "$myId",
"count": { "$sum": 1 }
}
}
])
each query is very fast (as index is being scanned) but since i need to call these group of 5 queries multiple times (say 5* 37) so its making the end-to-end api very slow .
what is the best appriach for this in mongo db ? as i am not very expect in mongoDB.
Any suggestions please?