java - Firestore 查询在 Geoquery 中工作两次
问题描述
我正在使用 Geoquery 从 Android 中的 Firestore 获取最近的文档。但不知何故,startAfter(lastVisible)
子句使查询为不同的绑定任务工作了两次。因此,在第一次获取之后,所有查询都会工作两次。
我的第一个查询是:
List<GeoQueryBounds> bounds = GeoFireUtils.getGeoHashQueryBounds(center, radiusInM);
final List<Task<QuerySnapshot>> tasks = new ArrayList<>();
for (GeoQueryBounds b : bounds) {
Query firstQuery = db.collection("posts")
.whereEqualTo("country_code", sharedpreferences.getString("country_code", ""))
.orderBy("geohash")
.startAt(b.startHash)
.endAt(b.endHash)
.limit(10);
tasks.add(firstQuery.get());
}
我的下一个查询是:
List<GeoQueryBounds> bounds = GeoFireUtils.getGeoHashQueryBounds(center, radiusInM);
final List<Task<QuerySnapshot>> nextTasks = new ArrayList<>();
for (GeoQueryBounds b : bounds) {
Query nextQuery = db.collection("posts")
.whereEqualTo("country_code", sharedpreferences.getString("country_code", ""))
.orderBy("geohash")
.startAt(b.startHash)
.endAt(b.endHash)
.startAfter(lastVisible)
.limit(10);
nextTasks.add(nextQuery.get());
}
解决方案
推荐阅读
- vba - 从打开的工作簿中提取数据的图表
- python - Python-Dbus 定义整数数组
- javascript - 博主数据:post.url 不起作用
- c - 为什么linux内核使用双重逻辑否定而不是强制转换为布尔值?
- regex - SAS PRXCHANGE 语句评估
- android - 什么时候应该使用fragment,什么时候应该使用activity?
- vba - Excel中的VBA自动更新图像尺寸
- seaborn - 具有正确缩放比例的 Seaborn Stripplot 轴值
- swift - 从堆栈中移除当前的 View Controller 并移动到新的 View Controller
- c# - 设计一个没有单个项目查找uri的rest api搜索是一种常见的模式吗?