首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >MongoDB、SpringData、findByPositionNear更多参数

MongoDB、SpringData、findByPositionNear更多参数
EN

Stack Overflow用户
提问于 2014-06-22 09:03:12
回答 1查看 187关注 0票数 0

您好,我有以下实现:

代码语言:javascript
复制
public class Store {
   private double[] position;
   private String category;
}

而这种搜索商店的方法即将出现

代码语言:javascript
复制
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;
}

但我需要按职位和类别进行搜索。如何为find添加参数类别?

EN

回答 1

Stack Overflow用户

发布于 2014-06-23 19:23:03

这就是你要找的吗?

代码语言:javascript
复制
interface StoreRepository extends Repository<Store, Long> {

  List<Store> findByCategoryAndPositionNear(String category, 
                                            Point point, Distance distance);
}

reference documentation中有更多关于这类东西的内容。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/24347255

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档