Hello,
I’m currently building an aggregation pipeline to get a rank of a user based on a certain property.
The pipeline looks as follows:
[
{
$setWindowFields:
/**
* query: The query in MQL.
*/
{
sortBy: {
kills: -1,
},
output: {
denseRankQuantityForState: {
$denseRank: {},
},
},
},
},
{
$project:
{
_id: "$_id",
type: "$type",
xuid: "$xuid",
kills: "$kills",
rank: "$denseRankQuantityForState",
},
},
{
$match:
{
xuid: "my_xuid",
type: 0,
},
},
]
There are indexes for type, xuid and type + xuid as a compound index.
It seems though that MongoDB is not able to leverage any of these indexes in the final matching step. Since that collection has over 4 million document entries, the query is way too slow (it exceeds the normal execution time limit.
Is there anything I can do to tell MongoDB to use one of my indexes?