[SERVER-27335] Unrecognized pipeline stage name: '$count' Created: 08/Dec/16  Updated: 27/Oct/23  Resolved: 08/Dec/16

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

Type: Bug Priority: Major - P3
Reporter: Roben Assignee: Kelsey Schubert
Resolution: Gone away Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Operating System: ALL
Participants:

 Description   

ubuntu@ip-172-31-26-220:~/code$ mongod --version
db version v3.2.3
git version: b326ba837cf6f49d65c2f85e1b70f6f31ece7937
OpenSSL version: OpenSSL 1.0.1f 6 Jan 2014
allocator: tcmalloc
modules: none
build environment:
    distmod: ubuntu1404
    distarch: x86_64
    target_arch: x86_64
 
> db.scores.find()
{ "_id" : 1, "subject" : "History", "score" : 88 }
{ "_id" : 2, "subject" : "History", "score" : 92 }
{ "_id" : 3, "subject" : "History", "score" : 97 }
{ "_id" : 4, "subject" : "History", "score" : 71 }
{ "_id" : 5, "subject" : "History", "score" : 79 }
{ "_id" : 6, "subject" : "History", "score" : 83 }
> 
 
> db.scores.aggregate(
...   [
...     {
...       $match: {
...         score: {
...           $gt: 80
...         }
...       }
...     },
...     {
...       $count: "passing_scores"
...     }
...   ]
... )
assert: command failed: {
        "ok" : 0,
        "errmsg" : "Unrecognized pipeline stage name: '$count'",
        "code" : 16436
} : aggregate failed
_getErrorWithCode@src/mongo/shell/utils.js:23:13
doassert@src/mongo/shell/assert.js:13:14
assert.commandWorked@src/mongo/shell/assert.js:266:5
DBCollection.prototype.aggregate@src/mongo/shell/collection.js:1215:5
@(shell):1:1
 
2016-12-08T20:48:42.551+0800 E QUERY    [thread1] Error: command failed: {
        "ok" : 0,
        "errmsg" : "Unrecognized pipeline stage name: '$count'",
        "code" : 16436
} : aggregate failed :
_getErrorWithCode@src/mongo/shell/utils.js:23:13
doassert@src/mongo/shell/assert.js:13:14
assert.commandWorked@src/mongo/shell/assert.js:266:5
DBCollection.prototype.aggregate@src/mongo/shell/collection.js:1215:5
@(shell):1:1
 
> 



 Comments   
Comment by Kelsey Schubert [ 08/Dec/16 ]

Hi narychen,

Please note that the $count stage was introduced in MongoDB 3.4. If you would like to make use of this feature, please upgrade.

Thank you,
Thomas

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