Hello !!
I’m trying to create a query in C# to obtain a ranking of a collection.
I have created the query and it works perfectly, but I am having problems translating it to C#.
I’m stuck at the SetWindowFields stage.
I understand that the Pipeline type is returning a different model, but I have looked at the documentation, but I have not seen an example that could explain to me where to point the problem.
I would appreciate some help. Thank you.
My query
db.getCollection('IntegratedMetricResults')
.aggregate( [
{
$match: {
AggregationKey: { $eq: "PlayerShotsMatchDaySum" },
AggregatorId: { $eq: UUID("f1db7f1f-63ae-4f85-938e-e456a9ff9477") }
}
},
{
$setWindowFields: {
partitionBy: "$AggregationKey",
sortBy: { Value: -1 },
output: {
rankOrder: {
$rank: {}
}
}
}
},
{
$project: {
AggregationKey: "$AggregationKey",
RefererId: "$RefererId",
Rank: "$rankOrder",
Value: "$Value"
}
},
{ $limit : 10 }
] );
