diff options
Diffstat (limited to 'jstests/aggregation/bugs/server26462.js')
-rw-r--r-- | jstests/aggregation/bugs/server26462.js | 40 |
1 files changed, 20 insertions, 20 deletions
diff --git a/jstests/aggregation/bugs/server26462.js b/jstests/aggregation/bugs/server26462.js index b0ef33ae35b..08225e54ce3 100644 --- a/jstests/aggregation/bugs/server26462.js +++ b/jstests/aggregation/bugs/server26462.js @@ -1,29 +1,29 @@ // Tests that adding a field that only contains metadata does not cause a segmentation fault when // grouping on the added field. (function() { - "use strict"; +"use strict"; - // Drop the old test collection, if any. - db.server26462.drop(); +// Drop the old test collection, if any. +db.server26462.drop(); - // Insert some test documents into the collection. - assert.writeOK(db.server26462.insert({"_id": 1, "title": "cakes and ale"})); - assert.writeOK(db.server26462.insert({"_id": 2, "title": "more cakes"})); - assert.writeOK(db.server26462.insert({"_id": 3, "title": "bread"})); - assert.writeOK(db.server26462.insert({"_id": 4, "title": "some cakes"})); +// Insert some test documents into the collection. +assert.writeOK(db.server26462.insert({"_id": 1, "title": "cakes and ale"})); +assert.writeOK(db.server26462.insert({"_id": 2, "title": "more cakes"})); +assert.writeOK(db.server26462.insert({"_id": 3, "title": "bread"})); +assert.writeOK(db.server26462.insert({"_id": 4, "title": "some cakes"})); - // Create a text index on the documents. - assert.commandWorked(db.server26462.createIndex({title: "text"})); +// Create a text index on the documents. +assert.commandWorked(db.server26462.createIndex({title: "text"})); - // Add a metadata only field in the aggregation pipeline and use that field in the $group _id. - let res = db.server26462 - .aggregate([ - {$match: {$text: {$search: "cake"}}}, - {$addFields: {fooScore: {$meta: "textScore"}}}, - {$group: {_id: "$fooScore", count: {$sum: 1}}} - ]) - .itcount(); +// Add a metadata only field in the aggregation pipeline and use that field in the $group _id. +let res = db.server26462 + .aggregate([ + {$match: {$text: {$search: "cake"}}}, + {$addFields: {fooScore: {$meta: "textScore"}}}, + {$group: {_id: "$fooScore", count: {$sum: 1}}} + ]) + .itcount(); - // Assert that the command worked. - assert.eq(2, res); +// Assert that the command worked. +assert.eq(2, res); })(); |