MongoDB $elemMatch $in MongoDB $elemMatch $in arrays arrays

MongoDB $elemMatch $in


You can use different syntax than the one you're trying that achieves the same result but doesn't run into the limitation in SERVER-3544.

Use this syntax:

db.collection.find({ "unusual": {"$elemMatch":{"defindex":363,"_particleEffect":{"$in":[6,19]}  }} })

This will match any document which has an array element with both 313 and either 6 or 19.

It also works with {$in:[]} for both defindex and _particleEffect, as long as you intend to match any combination of the two lists.

db.collection.find({ "unusual": {"$elemMatch":{"defindex":{"$in":[313,363]},"_particleEffect":{"$in":[6,19]}  }} })


https://jira.mongodb.org/browse/SERVER-3544

Welp, did a LOT of digging and it looks like that answers my question.You cannot do $in $elemmatch at this time.


Just try this (Tested)

{"unusual":  {         $all:[{            $elemMatch:{"defindex":313},            $elemMatch:{"_particleEffect":6}        }]    }}