I'm trying write a script and get data from collections added in year and particular month.
And also get the records where 'Name' field matches my given regex.
Is it possible to use regex group in aggregate? Something like this :
collection1.aggregate([
{"$match": {"$expr":{"$and":[{"$eq":[{"$year":"$updated_time"}, year]}, {"$eq":[{"$month":"$updated_time"}, month]}]}}},
{$group : {_id : {"Name": {"$regex": '^ABC', "$options": "i"} },count: { $sum: 1 }}
}]
Or which is the best way to get it? how do i modify this query to get count of regex match in that time frame