You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

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集合结构如下:
Firestore集合结构

Logcat偶尔会提示设备网络状态不佳,但我确认这不是问题的根源——从日志中可以看到AutoCompleteTextView的输入值已经被成功获取,但查询就是无法匹配到对应文档。

Logcat日志截图:
Logcat日志

恳请各位提供技术帮助,排查一下问题所在。

内容的提问来源于stack exchange,提问作者carlvindevzw

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.06 17:50:36