|
This ticket only covers the first issue, as the second is covered by SERVER-3406.
I would consider this to be working as designed. Consider the following query:
The semantics of this query are that a document matches if either:
- a is an array whose zeroth element is equal to 5, or
- a is an array containing a subdocument with the field 0 whose element is equal to 5, or
- a is a nested document which has a field 0 whose element is equal to 5.
Now consider the following three documents:
> c.find({}, {_id: 0, a: 1})
|
{ "a" : [ 5 ] }
|
{ "a" : [ { "0" : 5 } ] }
|
{ "a" : { "0" : 5 } }
|
{ "a" : [ [ 5 ] ] }
|
The first matches due to #1, the second matches due to #2, and the third matches due to #3. The fourth document, however, does not match!
> c.find({'a.0': 5}, {_id: 0, a: 1});
|
{ "a" : [ 5 ] }
|
{ "a" : [ { "0" : 5 } ] }
|
{ "a" : { "0" : 5 } }
|
On other hand, the document will match if the query is {"a.0": [5]} because the zeroth array element is equal to the nested array [5]:
> c.find({'a.0': [5]}, {_id: 0, a: 1});
|
{ "a" : [ [ 5 ] ] }
|
|