Aggregation $size: error when fieldpath field name contains a number

I’m trying to get the size of an array so that I can use the number that it returns in a for loop. I’m using mongodb compass. I’m trying to use something like the projection below where 0 is an object inside of path and “here” is an array with 2 items.
“alias” : {$size : “$”}
However, this keeps returning an array size of 0. It works fine for field paths that don’t contain a number in their path but returns 0 if the path does contain a number. Is there a way to properly get the correct size of the array here[] which has a size of 2?

Hi @science_cam

Welcome to MongoDB community.

So your field name is “0”? Or its an array under “path” field.

If its 0 its ambiguous to with an operator looking for first element in an array.

Maybe try `“$‘0’.here”, but if it doesn’t work I would suggest to rename the field to “zero” or do the length calc on application side…