您好跟随实施:
public class Store {
private double[] position;
private String category;
}
此搜索商店的方法接近
public List<Store> fundByLatLong(double latitude, double longitude, Double km) {
mongoTemplate.indexOps(Store.class).ensureIndex(new GeospatialIndex("position"));
Point point= new Point(latitude, longitude);
List<Store> stores= this.storeRepository.findByPositionNear(ponto , new Distance(km, Metrics.KILOMETERS));
return stores;
}
但我需要按职位和类别进行搜索。如何为查找添加参数类别?
答案 0 :(得分:1)
这是你要找的吗?
interface StoreRepository extends Repository<Store, Long> {
List<Store> findByCategoryAndPositionNear(String category,
Point point, Distance distance);
}
有关reference documentation中此类内容的更多信息。