1
是否可以將標準添加到NearQuery中?彈簧數據mongodb NearQuery添加另一個條件
目前,我這樣做:
public List<UserLocation> getUserNearLocation(Point p, double min, double max){
NearQuery query = NearQuery.near(p).minDistance(new Distance(min, Metrics.KILOMETERS)).maxDistance(new Distance(max, Metrics.KILOMETERS));
GeoResults<UserLocation> results = mongoTemplate.geoNear(query, UserLocation.class);
List<UserLocation> all = new ArrayList<UserLocation>();
Iterator<GeoResult<UserLocation>> iter = results.iterator();
while (iter.hasNext()){
GeoResult<UserLocation> temp = iter.next();
all.add(temp.getContent());
}
return all;
}
我想另一個標準添加到查詢,這可能又如何呢?
讓我明白,這是第二個查詢入隊的操作? – Sanandrea
它與本文所述的'geoNear'的查詢條件基本相同http://docs.mongodb.org/manual/reference/command/geoNear/#specify-a-query-condition –