Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mongo 2.6.1 - Unrecognized pipeline stage name: '$out'

Tags:

mongodb

I have a Mongo collection where I need to move an array of objects into a separate collection.

The collection is in this format:

{
    _id: ObjectId("..."),
    name: "...",
    description: "...",
    widgets: [
       { someprop: somevalue },
       { someprop: somevalue }
    ]
}

I'd like to unwind the object array into a separate collection.

According to the documentation for $out at http://docs.mongodb.org/manual/reference/operator/aggregation/out/ I should be able to use the operator to create a new collection.

The first two operations in the following Mongo shell command work to unwind the array into a list but it fails when I add the $out operation:

db.mytable.aggregate([
    { $project : {_id: 0, datasets : 1}},
    { $unwind : "$widgets"}, 
    { $out: "widgets"}
]);

Error:

Error: command failed: {
"errmsg" : "exception: Unrecognized pipeline stage name: '$out'",
"code" : 16436,
"ok" : 0
} : aggregate failed at src/mongo/shell/assert.js:13
like image 389
dr3x Avatar asked May 21 '14 17:05

dr3x


1 Answers

Make sure you're using the latest version. $out is new in 2.6, using 2.6.2 worked perfectly for me !

like image 89
sallah kokaina Avatar answered Sep 18 '22 11:09

sallah kokaina