$collection = Yii::$app->mongodb->getCollection('products');
$result = $collection->aggregate(array(
array(
'$match' => array('user_id' => $filter['user_id']),
),
array(
'$group' => array(
'_id' => array('city_id' => '$city_id'),
'count' => array( '$sum' => 1)
),
),
array(
'$limit' => 20
)
)
);