Hi there,
I have a successfully working aggregation pipeline for Mongo like:
Data:
{
id: 1234,
verbatim: clean
numeric: 4
},
{
id: 1234,
verbatim: dirt
numeric: 1
},
Aggregation:
{$group: {id: $id,
status: {
"$push": {
"verbatim": "$verbatim",
"numeric": "$numeric"
}
}}}
Projection:
{status: {
"$arrayElemAt": [
status.verbatim",
{
"$indexOfArray": [
"$status.numeric",
{"$max": "$status.numeric"}
]
}
]
}
This works fine with mongo, but does not with AWS DocumentDB because operator $indexOfArray is not supported.
How do I find an alternative way to find a verbatim field corresponding to maximal numeric?