我想要实现的是根据创建的事件提供建议位置列表。 例如。如果在20个事件(A /目的地)中搜索“LocationA”10次,它将返回此位置作为建议位置。
function locationsByFrequency() {
//aggregating the results first results will be empty as the number of location increase it will add to that.
return db.deliveries.aggregate(
[
//{ $group: { _id: "$location", total: { $sum: 1 } } },
//{ $sort: { total: -1 } }
{
$group: {
_id: "$location",
total: { $sum: 1 }
}
} ,
{ $sort: { total: -1 } }
]
);
}
mongo响应获取/为每个用户
[ location:address complete *
latitude:12.3434,*
longitude:32.42432*
}
work:
{
addressLine1: building name
addressLine2: tower and street name
subLocality: Sector 128
locality: Ntwtw
administrativeArea: testoneh
country: test
}
]