-
Type:
Improvement
-
Resolution: Won't Do
-
Priority:
Trivial - P5
-
None
-
Affects Version/s: None
-
Component/s: Aggregation Framework
-
Query
-
None
-
None
-
None
-
None
-
None
-
None
-
None
If $last operator is used in _id field for $group operation, for example:
db.test.aggregate([
{ $sort : { score : 1 }},
{ $group : {
_id : { name : "$name",
highest : { $last : "$score" }}}
}
])
the following error message is displayed:
{
"errmsg" : "exception: invalid operator '$last'",
"code" : 15999,
"ok" : 0
}
The error message is not so helpful for the user to fix the issue. It would help if we had a more specific error message, i.e. not to use $last in the _id field.
Similarly for $first operator.
BTW, the correct usage should be:
db.test.aggregate([
{ $sort : { score : 1 }},
{ $group : {
_id : { name : "$name" },
highest : { $last : "$score" }}
}
])
- related to
-
SERVER-9577 new deverloper question on usage of Aggregation Framework
-
- Closed
-