[SERVER-3406] double nested array element is implicitly extracted if it is addressed through an embedded field name, otherwise it isn't Created: 11/Jul/11  Updated: 28/Jan/15  Resolved: 28/Jan/15

Status: Closed
Project: Core Server
Component/s: Index Maintenance, Querying
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Aaron Staple Assignee: David Storch
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
related to SERVER-7385 Write named field extraction iterator... Closed
Operating System: ALL
Participants:

 Description   

> c.drop();
true
> c.save( {a:[[1]]} )
> c.find( {'a.0':1} )
> c.save( {a:[[{b:1}]]} )
> c.find( {'a.0.b':1} )
{ "_id" : ObjectId("4e154cf00157217a5f5f2989"), "a" : [ [ { "b" : 1 } ] ] }



 Comments   
Comment by David Storch [ 28/Jan/15 ]

I believe this is working as designed. For a more detailed description of the matching semantics at play here, see SERVER-3382.

I argue that the query

c.find( {'a.0.b':1} )

should match the document

{ "_id" : ObjectId("4e154cf00157217a5f5f2989"), "a" : [ [ { "b" : 1 } ] ] }

because it can be read as "the zeroth array element of a is an array containing a subdocument with b equal to 1". There are, of course, other valid matching semantics for this query, but nothing precludes this particular interpretation.

Generated at Thu Feb 08 03:02:58 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.