$push used too much memory and cannot spill to disk even though allowDiskUse: true

I am getting aggregation pipeline error PlanExecutor error during aggregation :: caused by :: $push used too much memory and cannot spill to disk. Memory limit: 104857600 bytes even though the allowDiskUse is set to true.

Having M10 Dedicated cluster

Here is the aggregation pipeline:

Blockquote
[
{
“$search”: {
“index”: “default”,
“compound”: {
“mustNot”: [
{
“wildcard”: {
“allowAnalyzedField”: true,
“query”: “…”,
“path”: “metadata.keyValue”
}
}
],
“filter”: [
{
“compound”: {
“should”: [
{
“equals”: {
“path”: “workscope”,
“value”: {
“$oid”: “68715538b55ee04f353a4411”
}
}
}
],
“minimumShouldMatch”: 1
}
}
],
“must”: [
{
“wildcard”: {
“allowAnalyzedField”: true,
“query”: [
“something;;;*”
],
“path”: “metadata.keyValue”
}
}
]
},
“returnStoredSource”: true
}
},
{
“$unwind”: “$metadata”
},
{
“$match”: {
“metadata.key”: {
“$in”: [
“Something”
]
}
}
},
{
“$group”: {
“_id”: {
“key”: “$metadata.key”,
“value”: “$metadata.value”,
“category”: “$metadata.category”
},
“count”: {
“$sum”: 1
}
}
},
{
“$group”: {
“_id”: {
“category”: “$_id.category”,
“key”: “$_id.key”
},
“values”: {
“$push”: {
“value”: “$_id.value”,
“count”: “$count”
}
}
}
},
{
“$group”: {
“_id”: “$_id.category”,
“keys”: {
“$push”: {
“key”: “$_id.key”,
“values”: “$values”
}
}
}
},
{
“$project”: {
“_id”: 0,
“category”: “$_id”,
“keys”: 1
}
}
]