【发布时间】:2023-02-07 22:46:25
【问题描述】:
在为 firebase 编写复合查询时,我遇到了一个问题。
我使用文档https://firebase.google.com/docs/firestore/solutions/geoqueries?hl=en&%3Bauthuser=0&authuser=0 中指定的 geoHash 过滤 除此之外,我想使用格式为“>=”或“<=”的其他排序标准。
同样在文档中写道,当使用运算符“>=”或“<=”时,有必要通过此属性设置顺序
当我使用我的参数编写查询时,它返回一个空数组。
请求看起来像这样:
query(
collection(db, '/some'),
where('some', '==', arg),
where('some another', '==', arg),
where('some another', 'array-contains-any', arg),
where('price', '>=', minPrice),
orderBy('price'),
orderBy('geoHash'),
startAt(b[0]),
endAt(b[1]),
limit(Math.ceil(DEFAULT_LIMIT_OF_LISTINGS - promises.length))
)
当我们添加按价格过滤并按价格排序时,查询不返回任何内容。
我通过将查询分为两个不同的部分来检查我的查询。一切正常。我的数据也没有问题。控制台中也没有来自 firebase 的错误
【问题讨论】:
-
你创建了一个index吗?
标签: javascript firebase google-cloud-firestore geohashing