-
Type: Bug
-
Resolution: Duplicate
-
Priority: Major - P3
-
None
-
Affects Version/s: 2.6.7
-
Component/s: Querying
-
None
-
ALL
Having a collection with elements with a 'tags' array, where each element in the array is {k:<key>, v:<value>}, with an index {'tags.k': 1, 'tags.v': 1}
A query of the form
db.coll.find({tags : { "$elemMatch" : { k : "somekey", v : "somevalue" } } })
correctly makes use of the index. However, a query like:
db.coll.find({tags : {$all: [ { "$elemMatch" : { k : "somekey", v : "somevalue" } } ] } })
does not make use of the index and produces a full scan
(note: the use of $all is to allow search matching on more than one tag)
- duplicates
-
SERVER-16256 $all clause with elemMatch uses wider bounds than needed
- Closed