In a MongoDb aggregation pipeline, I often encounter wanting to filter on an operation of a member field (i.e. size of a list). Is it possible doing this in one operation, rather than projecting a variable first, and then matching?
This is what I usually do:
[
{
"$project": {
"vector_size": { "$size": "$VectorField" }
}
},
{
"$match": {
"vector_size": { "$gte": 7 }
}
}
]
I would prefer a one-off, something like:
[
{
"$match": {
"VectorField": { "$size": { "$gte": 7 } }
}
}
]
But for that operation $size
expects an integer, and not another operation.
It it possible?