You need to enable JavaScript to run this app. Cloud Firestore 按Europe/Chisinau时区查询用户返回空列表
优惠活动
大模型
产品
解决方案
定价
更多

Cloud Firestore 按Europe/Chisinau时区查询用户返回空列表

场景需求

我需要查询所有时区为Europe/Chisinau的用户,这类用户的文档结构示例如下:

'device': {
    'from': '{"status":"success","country":"Moldova","countryCode":"MD","zip":"MD-3300","timezone":"Europe/Chisinau"}'
}

需要说明的是,上述结构中的device.from字段为字符串类型,其取值是一段序列化后的JSON字符串,真正的时区信息就存储在这段序列化字符串内部。

问题复现

我编写了如下代码执行查询:

# 初始化Firestore客户端
from google.cloud import firestore
firestore_client = firestore.Client.from_service_account_json('creds.json')
ref = firestore_client.collection('databases').document('testing')

# 执行范围查询匹配Europe/Chisinau
ref.collection(u'users').where(u'device.from', u'>=', u'Europe/Chisinau').where(u'device.from', u'<=', u'Europe/Chisinau').get()
# 实际返回结果:[]

上述代码执行后始终返回空列表。
我当前使用的Firestore开发依赖来自官方维护的GoogleCloudPlatform/python-docs-samples代码库,未修改SDK核心查询逻辑。


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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.10.31 05:54:05