I have a mongodb of about 400gb. The documents contain a variety of fields, but the key here is an array of IDs.
So a json file might look like this
Try this:
db.users.aggregate( [ { $unwind : "$key" }, { $group : { _id : "$key", number : { $sum : 1 } } }, { $sort : { number : -1 } }, { $limit : 10000 }, { $out:"result"}, ], { allowDiskUse:true, cursor:{} } );
Then find result by db.result.find().
db.result.find()