+-
MongoDB使用聚合$facet报错

查询条件如下

db.doc_user_orders.aggregate([ { $match: { "orgGroup": "汽车事业群" } }, { $facet: { "data": [ { $sort: { "_id": -1 } }, { $skip: 0 }, { $limit: 10 } ], "total": [ { $count: "total" } ] } } ])

报错如下:

assert: command failed: { "ok" : 0, "errmsg" : "Unrecognized pipeline stage name: '$facet'", "code" : 16436 } : aggregate failed _getErrorWithCode@src/mongo/shell/utils.js:25:13 doassert@src/mongo/shell/assert.js:13:14 assert.commandWorked@src/mongo/shell/assert.js:287:5 DBCollection.prototype.aggregate@src/mongo/shell/collection.js:1312:5 @(shell):1:1 2021-04-16T15:35:51.449+0800 E QUERY [thread1] Error: command failed: { "ok" : 0, "errmsg" : "Unrecognized pipeline stage name: '$facet'", "code" : 16436 } : aggregate failed : _getErrorWithCode@src/mongo/shell/utils.js:25:13 doassert@src/mongo/shell/assert.js:13:14 assert.commandWorked@src/mongo/shell/assert.js:287:5 DBCollection.prototype.aggregate@src/mongo/shell/collection.js:1312:5 @(shell):1:1

这个是什么原因?

写的没问题啊, facet是3.4以上的, 版本不对?