【问题标题】:How to index documents automatically once added in Firestore according to a Field?一旦根据字​​段添加到 Firestore 中,如何自动索引文档?
【发布时间】:2018-11-16 18:47:38
【问题描述】:

我正在使用 firestore 制作类似于 leaderboard 的东西,所以我希望 Result 集合的文档在数据库中自动被索引根据 TimeDESCENDING 在客户端上显示,以便在客户端显示,这是一个 android 应用程序

我的 Firestore 数据库如下所示:

   Results:------------------------>(collection)

          {bcmskdjdkd}:------------->(document)
                     Time:22.3------->(Field)
          {trhrthrtht}:
                     Time:21.5
          {xfgndrghnt}:
                     Time:24.6

【问题讨论】:

    标签: android firebase google-cloud-firestore google-cloud-functions


    【解决方案1】:

    如果您使用相关字段的查询未产生错误,则无需创建任何索引。 Firestore 根本不会执行它无法有效满足的查询。

    Please read the documentation to understand Firestore indexes.

    所有文档字段都被自动索引,因此只使用相等子句的查询不需要额外的索引。如果您尝试使用未映射到现有索引的范围子句进行复合查询,则会收到错误消息。错误消息包含在 Firebase 控制台中创建缺失索引的直接链接。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-06-26
      • 2018-12-22
      • 2020-04-25
      • 2019-09-23
      • 1970-01-01
      • 2018-04-03
      相关资源
      最近更新 更多