Operator $type does not finds array (type=4) elements.
It tested db, 'aList' field is array. There are records with empty arrays and not empty.
But request to count elemets by type = array brings zero (0) results;
>db.mydata.count({ aList: {$type: 4 } }); //type = Array
0
Meantime, the following check shows that there are arrays, and som of them are non-empty:
> var obj = db.mydata.count({ aList: {$type:3} }); //type = Object
> obj
33276
> var zero = db.mydata.count({ aList: {$size: 0 } }); //empty arrays
> zero
421251
> var all = db.mydata.count({ }); //all records
> all
454527
> all - zero // number of non- empty arrays
33276
As you see, obj == (all - zero) - all arrays are treated as Objects(type=3)!
Expected: array fileds should be treated as Arrays (type=4).
- is duplicated by
-
SERVER-1854 $type not working properly with arrays
- Closed
-
SERVER-38770 "$type" cannot match array in version 3.4.4
- Closed
- related to
-
SERVER-51303 Lookup stage followed by $match on type uses wrong field in matching condition
- Closed
-
SERVER-29163 Version match expressions
- Backlog