[SERVER-6075] Accessing array elements by position fails in $project Created: 12/Jun/12  Updated: 12/Jun/12  Resolved: 12/Jun/12

Status: Closed
Project: Core Server
Component/s: Aggregation Framework
Affects Version/s: 2.1.2
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Matt Weyant Assignee: Unassigned
Resolution: Duplicate Votes: 3
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
duplicates SERVER-4589 aggregation: need an array indexing ... Closed
Operating System: ALL
Participants:

 Description   

Insert some data:
db.foo.insert({title:"A doc", intervals:[

{value:1, x:"a"}

,

{value:2,x:"b"}

,

{value:3,x:"c"}

]});

Verify it's there:
db.foo.find()
{ "_id" : ObjectId("4fd776800821eeb296a71a70"), "title" : "A doc", "intervals" : [

{"value" : 1, "x" : "a"}

,

{"value" : 2, "x" : "b"}

,

{"value" : 3, "x" : "c"}

] }

Try a projection:
db.foo.aggregate({$project:{title:1, i1:"$intervals.0"}})
{
"errmsg" : "exception: assertion src/mongo/db/pipeline/value.cpp:446",
"code" : 0,
"ok" : 0
}

Try another:
db.foo.aggregate({$project:{title:1, i1:"$intervals.0.value"}})
{
"errmsg" : "exception: assertion src/mongo/db/pipeline/value.cpp:446",
"code" : 0,
"ok" : 0
}



 Comments   
Comment by Ian Whalen (Inactive) [ 12/Jun/12 ]

Closing as dupe of SERVER-4589. Please comment if you believe there is something in your request not covered there.

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