【问题标题】:Firebase database indexes for many fields that I could query我可以查询的许多字段的 Firebase 数据库索引
【发布时间】:2020-10-15 19:45:11
【问题描述】:

我在 firebase (cloud firestore) 中有一个集合,其中包含以下字段:状态、角色、国家/地区、createdAt。我想根据任意数量的字段和字段组合来查询这个集合。

现在我真的必须为我可以查询的每个组合创建一个索引吗?假设我不使用 Algolia 等搜索服务。

例如:

country Ascending role Ascending createdAt Descending
role Ascending country Ascending createdAt Descending
status Ascending country Ascending role Ascending createdAt Descending
etc.....

【问题讨论】:

    标签: firebase google-cloud-firestore


    【解决方案1】:

    是的,您必须为支持在其中一个字段上使用范围过滤器进行查询的每个字段组合创建一个索引。我建议查看documentation on index types

    Cloud Firestore 不会像单字段索引那样自动创建复合索引,因为可能存在大量字段组合。相反,Cloud Firestore 可帮助您在构建应用时识别和创建所需的复合索引。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-01-23
      • 2022-06-10
      • 2017-04-25
      • 1970-01-01
      • 2017-10-13
      • 1970-01-01
      相关资源
      最近更新 更多