[SERVER-15083] Allow projection of specific array elements by position Created: 28/Aug/14  Updated: 14/Apr/16  Resolved: 08/Apr/15

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

Type: Improvement Priority: Major - P3
Reporter: Ramon Fernandez Marina Assignee: Unassigned
Resolution: Duplicate Votes: 0
Labels: projection
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
duplicates SERVER-6074 Allow $slice operator in $project Closed
Related
related to SERVER-15013 Projection of field in a concrete arr... Closed
Backwards Compatibility: Fully Compatible
Participants:

 Description   

This appeared in SERVER-15013:

It is ambiguous whether "0" refers to a nested field name or to a position in the array. For instance, what should the following projection return?

t.insert({a: [{"0": "foo", "bar": "baz"}, {"a": "b"}]});
t.find({}, {"a.0": 1});

One answer is that "0" should be interpreted as an array position, meaning that we should project just the first array element. The transformed document would then be:

{a: [ {"0": "foo", "bar": "baz"} ]}

Another answer is that "0" should be interpreted just like any other field name, and should be used to project within each nested document. Under this interpretation, the result is:

{ "a" : [ { "0" : "foo" }, {  } ] }

Our projection language chooses the latter interpretation.


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