4

when I run this aggregation pipeline in Robomongo

db.getCollection('xyz').aggregate([{$match: {tyu: "asd", ghj: "qwe"}},
{$sample: {size: 5}}])

I receive this error:

assert: command failed: {
"errmsg" : "exception: Unrecognized pipeline stage name: '$sample'",
"code" : 16436,
"ok" : 0

I'm using mongodb ver 3.2.6 and since $sample is supported from 3.2 onward. (https://docs.mongodb.com/manual/reference/operator/aggregation/sample/#pipe._S_sample)

Im a little confused as to why I receive this error message.

Maybe I'm just missing something small.

Thanks

kevinadi
  • 13,365
  • 3
  • 33
  • 49
HongerTrollie
  • 301
  • 3
  • 9
  • Have a look in to the comments of this [question](http://stackoverflow.com/questions/23790525/mongo-2-6-1-unrecognized-pipeline-stage-name-out), which may help you. – Shrabanee Jul 07 '16 at 10:47
  • 2
    Thanks. In the shell version() shows 3.2.6 but db.version() shows 3.0.6. – HongerTrollie Jul 07 '16 at 20:11

1 Answers1

4

As stated in the comments of the question. Mongo client had a version of 3.2.6 but Mongo db had a version of 3.0.6.

I used version() in the shell to get the client's version and db.version() to get the DB's version.

ver 3.0.6 is too low to support $sample as stated in the mongo documentation https://docs.mongodb.com/manual/reference/operator/aggregation/sample/#pipe._S_sample

ʰᵈˑ
  • 11,279
  • 3
  • 26
  • 49
HongerTrollie
  • 301
  • 3
  • 9