Hi
I have wildcard index all over the collection.
I’m trying to get a list of unique values
I tried to use
"pipeline": [
{
"$group": {
"uniqueValues": {
"$addToSet": "$project"
},
"_id": null
}
}
]
But it was super slow then I read that in order to use the field index I should add the sort stage before, so I tried this one:
"pipeline": [
{
"$sort": {
"project": 1
}
},
{
"$group": {
"uniqueValues": {
"$addToSet": "$project"
},
"_id": null
}
}
]
But still it not using the index (“planSummary”: [ { “COLLSCAN”: {} } ]) and now I got “errMsg”: “Sort exceeded memory limit of 104857600 bytes, but did not opt in to external sorting.”
How can I get the unique values and use the wildcard index?
Thank you