I’m trying to this aggregation for a collection but getting memory limit error, then i used allowDiskUse: true . But it’s not working.
My aggreagation:
[
{
"$match": {
"createdAt": {
"$gte": ISODate("2024-05-15T14:42:55Z"),
"$lte": ISODate("2024-07-15T14:42:55Z")
}
}
},
{
"$group": {
"_id": "$keyword",
"count": { "$sum": 1 },
"unique_ips": { "$addToSet": "$remoteHost" }
}
},
{
"$project": {
"count": 1,
"unique_ip_count": { "$size": "$unique_ips" }
}
},
{
"$sort": { "count": -1 }
},
{
"$limit": 20
}
]
Errror:
PlanExecutor error during aggregation :: caused by :: Exceeded memory limit for $group, but didn't allow external spilling; pass allowDiskUse:true to opt in, full