Subject: Mongo Framework Aggregation help Hello Dev Support, I have a dumb little script that I can seem to get working. I have a collection of Java Garbage Collection documents, I want to search and get the last free percentage of memory for each port/host. I'm sure I'm doing something stupid, but the error message doesn't really help me …. Regards, Craig Curtin (201)557-1132 BAML ============ MongoDB shell version: 2.4.1 script: // specify which database to use use tmp // call the aggregator on all documents in the collection db.RSgc.ensureIndex( { utime: 1 } ) db.RSgc.aggregate( [ // now group the documents how we want to see them { $group : { _id : { myhost : "$host", myport : "$port", //freeMem : { $last : "$postFreePct" }, } } } ] ) ouput: { "_id" : { "myhost" : "mrsp3.mrisk.bankofamerica.com", "myport" : 4311 } }, { "_id" : { "myhost" : "mrsp2.mrisk.bankofamerica.com", "myport" : 4306 } } ], "ok" : 1 ... all is good and well, now I want the "Last Free memory Percentage", so I uncomment above and get: Error message: -sh-3.2$ ./mongo < mongJira.20130503 MongoDB shell version: 2.4.1 Fri May 3 13:42:46.186 versionArrayTest passed connecting to: tmp Fri May 3 13:42:46.221 creating new connection to:127.0.0.1:27017 Fri May 3 13:42:46.221 BackgroundJob starting: ConnectBG Fri May 3 13:42:46.221 connected connection! switched to db tmp Error: Printing Stack Trace at printStackTrace (src/mongo/shell/utils.js:37:7) at DBCollection.aggregate (src/mongo/shell/collection.js:897:1) at (shell):1:9 Fri May 3 13:42:46.297 JavaScript execution failed: aggregate failed: { "code" : 15999, "ok" : 0, "errmsg" : "exception: invalid operator '$last'" } at src/mongo/shell/collection.js:L898 bye this are few sample documents { "_id": ObjectId("5182d7a1b81bd203f42f99e9"), "upTime": 117.99439277778, "gcMode": "GC(Partial)", "postFreePct": 46.314380787037, "postMem": NumberInt(29686), "freeMemStr": "012345", "host": "mrsp6.mrisk.bankofamerica.com", "recvMem": NumberInt(3), "time": ISODate("2013-05-02T21:15:47.0Z"), "maxHeapSize": NumberInt(55296), "port": NumberInt(4329), "utime": NumberLong(1367529347) } { "_id": ObjectId("5182d7a1b81bd203f42f99e8"), "upTime": 117.99413083333, "gcMode": "GC(Partial)", "postFreePct": 46.355975115741, "postMem": NumberInt(29663), "freeMemStr": "012345", "host": "mrsp6.mrisk.bankofamerica.com", "recvMem": NumberInt(9), "time": ISODate("2013-05-02T21:15:46.0Z"), "maxHeapSize": NumberInt(55296), "port": NumberInt(4329), "utime": NumberLong(1367529346) }