4

我正在使用 MongoDB 的地理空间查询函数和 Spring Data MongoDB 编写一个 LBS 应用程序。以下是使用存储库查询地理结果的代码:

GeoPage<RestaurantLocation> results = restaurantLocationRepository.findByLocationNear(point, distance, new PageRequest(0, 1));

我的测试 MongoDB 实例中有 5RestaurantLocation条记录(全部在距离内),我希望此查询仅返回 1 条记录(页面大小为 1),但返回的GeoPage包含所有 5 条记录。

相反,当我将代码更改为以下内容时:

Page<RestaurantLocation> results = restaurantLocationRepository.findByLocationNear(point , distance, new PageRequest(0, 1));

分页按预期工作。它只返回 1 条记录,但它不是GeoResult.

我想要的是分页GeoResultRestaurantLocation

4

0 回答 0