Android Firestore在查询中返回已删除的文档

Android Firestore在查询中返回已删除的文档,android,firebase,kotlin,google-cloud-firestore,geofire,Android,Firebase,Kotlin,Google Cloud Firestore,Geofire,我正在使用的是'sGeoQueryDataEventListener 目前,我正在使用2台设备进行测试User1搜索查看附近是否有其他文档,如果没有文档存在,则创建新文档。然后,User2将搜索并查找User1的文档 问题是,当User2执行地理查询时,它通常会返回已删除的文档 我不想从缓存中检索文档。如果服务器上不存在文档,我不想将其返回。我已在代码中关闭缓存持久性: val settings: FirebaseFirestoreSettings = FirebaseFirestoreSett

我正在使用的是's
GeoQueryDataEventListener

目前,我正在使用2台设备进行测试
User1
搜索查看附近是否有其他文档,如果没有文档存在,则创建新文档。然后,
User2
将搜索并查找User1的文档

问题是,当
User2
执行地理查询时,它通常会返回已删除的文档

我不想从缓存中检索文档。如果服务器上不存在文档,我不想将其返回。我已在代码中关闭缓存持久性:

val settings: FirebaseFirestoreSettings = FirebaseFirestoreSettings.Builder().setPersistenceEnabled(false).build()
val db by lazy { FirebaseFirestore.getInstance() }

db.firestoreSettings = settings
然而,my
GeoQuery
仍然从缓存返回文档

话虽如此,大部分时间
GeoFire
表示文档来自缓存,但它不是:

示例1-删除了以下ID为
z2sniJhKrWpZhX
的文档。然后我查询了数据库,该文档在
onDocumentEntered
中返回:

nearbyUsers = geoFirestore.queryAtLocation(currentLocation, 1.0)
nearbyUsers.addGeoQueryDataEventListener(object : GeoQueryDataEventListener {

override fun onDocumentEntered(documentSnapshot: DocumentSnapshot, location: GeoPoint) {
                Log.d(TAG, "onDocumentEntered: user1: ${documentSnapshot.getString("user1")} | docId: ${documentSnapshot.id} | fromCache: ${documentSnapshot.metadata.isFromCache}")

onDocumentEntered: user1: 6IXCuAzK76JWP7F3h414IShm1 | docId: z2sniJhKrWpZhX | fromCache: true
nearbyUsers = geoFirestore.queryAtLocation(currentLocation, 1.0)
nearbyUsers.addGeoQueryDataEventListener(object : GeoQueryDataEventListener {

override fun onDocumentEntered(documentSnapshot: DocumentSnapshot, location: GeoPoint) {
                Log.d(TAG, "onDocumentEntered: user1: ${documentSnapshot.getString("user1")} | docId: ${documentSnapshot.id} | fromCache: ${documentSnapshot.metadata.isFromCache}")

onDocumentEntered: user1: 6IXCuAzK76JWP7F3h414IShm1 | docId: yRFjKHEyGXclKcS | fromCache: true
示例2-以下ID为
YRFJKEYGXCLKCS
的文档未被删除。然后我查询了数据库,该文档在
onDocumentEntered
中返回:

nearbyUsers = geoFirestore.queryAtLocation(currentLocation, 1.0)
nearbyUsers.addGeoQueryDataEventListener(object : GeoQueryDataEventListener {

override fun onDocumentEntered(documentSnapshot: DocumentSnapshot, location: GeoPoint) {
                Log.d(TAG, "onDocumentEntered: user1: ${documentSnapshot.getString("user1")} | docId: ${documentSnapshot.id} | fromCache: ${documentSnapshot.metadata.isFromCache}")

onDocumentEntered: user1: 6IXCuAzK76JWP7F3h414IShm1 | docId: z2sniJhKrWpZhX | fromCache: true
nearbyUsers = geoFirestore.queryAtLocation(currentLocation, 1.0)
nearbyUsers.addGeoQueryDataEventListener(object : GeoQueryDataEventListener {

override fun onDocumentEntered(documentSnapshot: DocumentSnapshot, location: GeoPoint) {
                Log.d(TAG, "onDocumentEntered: user1: ${documentSnapshot.getString("user1")} | docId: ${documentSnapshot.id} | fromCache: ${documentSnapshot.metadata.isFromCache}")

onDocumentEntered: user1: 6IXCuAzK76JWP7F3h414IShm1 | docId: yRFjKHEyGXclKcS | fromCache: true
这两个文档显然都来自缓存,即使其中一个在服务器上是实时的

我只想执行一个
GeoQuery
(),返回实时文档(无缓存)。如果这不可能,我很乐意根据
documentSnapshot.metadata.isFromCache
进行筛选-但即使这样也不可能,因为有时它会说文档来自缓存,尽管它不是

任何建议都将不胜感激

编辑:如果我从
onDocumentEntered()
检索文档,它通常是第一次从缓存中检索的。然后,如果执行
GeoQuery.removeAllListeners()
,然后再次执行,将检索相同的文档,但不会从缓存中检索。它说,如果我连接到互联网,我应该收到来自服务器的第二次回调,但是我必须在一个单独的调用中查询数据库。我需要在第一次尝试时从服务器(而不是缓存)检索文档。我怎样才能做到这一点