Em MongoDB 3.2 ou posterior, ordene por timestamp decrescente, agrupe por chave, empilhe valores e use $slice para manter os mais recentes.
db.collection.aggregate([
{ $sort: { created: -1 } },
{
$group: {
_id: '$city',
title: { $push: '$title' }
}
},
{
$project: {
_id: 0,
city: '$_id',
mostRecentTitle: { $slice: ['$title', 0, 2] }
}
}
])Versões antigas podem exigir coleção temporária e update posterior.