用户将向我发送他想获取客户的纬度,经度和范围(距离),以下是我尝试获取的JSON和查询,但其不起作用,请帮我解决这个问题(Mongodb和Spring引导)
My JSON:
**{
"_id" : ObjectId("56953353e4b0f47b5f19f468"),
"addrName" : "The Center",
"addrLine1" : "The Center",
"country" : "Bahamas",
"position" : [
-77.313576,
25.072286
],
"baseLocation" : true,
}
{
"_id" : ObjectId("5695337ee4b0f47b5f19f46a"),
"addrName" : "The Village",
"addrLine1" : "The Village",
"country" : "Bahamas",
"position" : [
-77.313576,
25.072286
],
"baseLocation" : true,
}**
My Query:
**Point point = new Point(lat,lon);
Distance newdistance = new Distance(distance, Metrics.MILES);
Query addressQuery2 = new Query(Criteria.where("position").nearSphere(point).maxDistance(distance))
.with(request);
addressList = mongoOps.find(addressQuery2, Address.class, "address");**