Mongo can’t canonicalize query: BadValue $in needs an array

Error: From MongoDB 2.6, $in need an numerical indexed array. Associative array or malformed numerical indexed array like these will raise BadValue error:

array(‘apple’->’iphone’, ‘nokia’->’winphone’)

array(0->’a’, ‘2’->b)

Solution:

In PHP, use array_values($array) to get the numerical indexed array as input for $in query

Mongo can’t canonicalize query: BadValue $in needs an array