database - 我可以使用 where equals 子句和 orderby 查询 Cloud Firestore 集合吗?

标签 database firebase indexing google-cloud-firestore

documentation状态:

However, if you have a filter with a range comparison (<, <=, >, >=), your first ordering must be on the same field:

这意味着我可以将非范围比较“==”与 orderBy 子句一起使用。但这失败了:

myCollectionRef.where('age', '==', 2).orderBy('name');

最佳答案

如果您想使用一个或多个相等过滤器对查询进行排序,而排序是按不同的字段进行的,则需要创建一个复合索引。

您可以在我们的 "Managing Indexes" 中阅读更多相关信息文档部分。

关于database - 我可以使用 where equals 子句和 orderby 查询 Cloud Firestore 集合吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46821757/

相关文章:

c# - 使用 Install Shield 安装程序在用户计算机上部署时如何使用 c# 应用程序附加 MS Access 数据库文件?

mysql - 创建数据库时,最好对每个表中的所有主键进行散列处理吗?

javascript - 如何将 Firebase 子项中的值排序到其余值?

python - 使用 `loc` 进行 Pandas bool 选择并不总是更快?

sql - 获取sql server中表和索引的存储大小

database - 在 application.conf 中为 Play 2.0/anorm 加密数据库密码

database - Impala中的数据库架构

java - 如何减少 Firestore 集合中的读取次数?

FIrebase电话身份验证支持的国家/地区?

python - 如何在 Pandas 的一个数据框中对两个类别进行分类