在Spring数据Mongodb中,I';我无法指定限制值来限制结果的数量
下面是Spring存储库类 公共接口UserRepository扩展了MongoRepository{在Spring数据Mongodb中,I';我无法指定限制值来限制结果的数量,mongodb,limit,spring-data,Mongodb,Limit,Spring Data,下面是Spring存储库类 公共接口UserRepository扩展了MongoRepository{ @Query(value = "{location :{ $nearSphere :{$geometry : {type : \"Point\", coordinates : [?1, ?0] }, $maxDistance :?2}}") List<User> search(float latitude, float longitude, float radius, int li
@Query(value = "{location :{ $nearSphere :{$geometry : {type : \"Point\", coordinates : [?1, ?0] }, $maxDistance :?2}}")
List<User> search(float latitude, float longitude, float radius, int limit);
@Query(value=“{location:{$nearSphere:{$geometry:{type:\'Point\”,坐标:[1,?0]},$maxDistance:?2}”)
列表搜索(浮动纬度、浮动经度、浮动半径、整数限制);
}
我无法使用limit()函数限制搜索函数返回的结果总数。我已尝试在@Query annotation中的所有位置添加limit()。使用存储库抽象允许您添加一个
Pageable
参数(将自动拾取以执行查询)方法签名
@Query(value = "{location :{ $nearSphere :{$geometry : {type : \"Point\", coordinates : [?1, ?0] }, $maxDistance :?2}}")
List<User> search(float latitude, float longitude, float radius, Pageable page);
您可以在参考手册中找到更多的示例。使用存储库抽象允许您向方法签名添加一个
Pageable
参数(将自动拾取以执行查询)
@Query(value = "{location :{ $nearSphere :{$geometry : {type : \"Point\", coordinates : [?1, ?0] }, $maxDistance :?2}}")
List<User> search(float latitude, float longitude, float radius, Pageable page);
您可以在参考手册中找到和的更多示例