cursor = db.flow.aggregate([
    {
        $match : {
            timeFirst : { $gte : time_from },
            timeLast  : { $lte : time_to },
        }
    },
    {
        $unwind : "$httpMimes"
    },
    {
        $match : {
            httpMimes : { $regex : /\// }
        }
    },
    {
        $project : {
            mime : {
                $slice : [
                    {
                        $split : [
                            { $toLower : "$httpMimes" },
                            "/"
                        ]
                    },
                    1
                ]
            }
        }
    },
    {
        $group : {
            _id : "$mime",
            count : { $sum : 1 }
        }
    },
    {
        $sort : { count : -1 }
    },
    {
        $limit : n
    }
])

cursor.forEach(
    function(e) {
        print(
              e._id + "\t"
            + e.count
        )
    }
)
