I have documents of the form:

{a: [ { b: 1, c: 2 }, { b: 3, c: 4 } ]}

I need to find all documents that match a given b and c value in the same nested object. How can I do that? And what is the shape of the index?

I can only figure out a find that automatically enumerates the array in a, and the result is incorrect:

test> db.hx2a.findOne({"$and":[{“a.b”:{"$eq":1}},{“a.c”:{"$eq":4}}]})

{

_id: ObjectId(“62c45959c5da24a18acfa3e8”),

a: [ { b: 1, c: 2 }, { b: 3, c: 4 } ]

}

The values are in two different nested objects, not in the same one.

Thanks!