cursor = db.flow.aggregate([
    {
        $match : {
            dnsStat : { $bitsAllClear : NumberInt(0x12) },
            timeFirst : { $gte : time_from },
            timeLast  : { $lte : time_to },
        }
    },
    {
        $unwind : "$dns6Aaddress"
    },
    {
        $group : {
            _id : "$dns6Aaddress",
            count : { $sum : 1 }
        }
    },
    {
        $match : {
            _id : { $ne : "::" }
        }
    },
    {
        $sort : { count : -1 }
    },
    {
        $limit : n
    }
])

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