Firestore查询特定Countries集合无结果,请求技术排查帮助
Firestore Countries集合查询无结果问题
我在尝试从Firestore的Countries集合中,根据输入的国家名称匹配countryName字段、获取对应文档ID时遇到了问题:查询始终没有返回任何结果,但将相同的查询逻辑换到其他集合上执行时,所有功能都能正常运行。目前除了这个数据查询环节,其他功能均无异常。
我的查询代码如下:
val country = binding.autoCompleteTv.text.toString().trim() Log.d(BusinessDetailsFragment.TAG, country) firebaseFirestore.collection("Countries") .whereEqualTo("countryName", country) .get() .addOnSuccessListener { documents -> for (document in documents) { Log.d(BusinessDetailsFragment.TAG, "${document.id} => ${document.data}") countryID = document.id Toast.makeText(this, countryID, Toast.LENGTH_SHORT).show() } } .addOnFailureListener { exception -> Log.w(BusinessDetailsFragment.TAG, "Error getting documents: ", exception) }
我的Firestore集合结构如下:
Logcat偶尔会提示设备网络状态不佳,但我确认这不是问题的根源——从日志中可以看到AutoCompleteTextView的输入值已经被成功获取,但查询就是无法匹配到对应文档。
Logcat日志截图:
恳请各位提供技术帮助,排查一下问题所在。
内容的提问来源于stack exchange,提问作者carlvindevzw
相关产品推荐
相关产品推荐

