【发布时间】:2022-01-18 02:59:45
【问题描述】:
我为一个集合创建一个索引
数据库
收藏:收藏1 数据示例:
{
date: 1638926138,
azd: { la: 481.120599, lo: 221.0256055 },
po: 123456,
st: 123456,
user: OeS2,
}
索引 1
ID 集合:collection1 字段索引:azd.la -> 升序,日期 => 降序, 状态:激活
请求 1
我从这个请求开始,它的工作
firestore()
.collection(COLLECTION)
.orderBy("azd.la")
.where("azd.la", ">=", a_min)
.where("azd.la", "<=", a_max)
.orderBy('date', 'desc')
.get()
如果我用 3 个属性(azd.la、azd.lo、日期)更新我的索引
索引 1 已更新
ID 集合:collection1 字段索引:azd.la -> 升序,azd.lo -> 升序,日期 => 降序, 状态:激活
firestore()
.collection(COLLECTION)
.orderBy("azd.la")
.where("azd.la", ">=", a_min)
.where("azd.la", "<=", a_max)
.orderby("azd.lo")
.where("azd.lo", ">=", b_min)
.where("azd.lo", "<=", b_max)
.orderBy('date', 'desc')
.get()
我有一个错误 可能的未处理承诺拒绝(id:0): 错误:firebase.firestore().collection().where() 查询无效。具有不等式(、!= 或 >=)的所有 where 过滤器必须位于同一字段中。但是您在“azd.la”和“azd.lo”上有不等式过滤器
我有另一个索引,但我不知道问题是否完全相同
索引 2
ID 集合:collection1 字段索引:azd.la -> 升序,azd.lo -> 升序,po -> 升序,日期 => 降序, 状态:激活
firestore()
.collection(COLLECTION)
.orderBy("azd.la")
.where("azd.la", ">=", a_min)
.where("azd.la", "<=", a_max)
.orderby("azd.lo")
.where("azd.lo", ">=", b_min)
.where("azd.lo", "<=", b_max)
.orderby("po")
.where("po", "==", 123456)
.orderBy('date', 'desc')
.get()
感谢您的帮助
【问题讨论】:
标签: javascript firebase react-native google-cloud-firestore