【问题标题】:Firebase/Firestore no matching index found but no option to create oneFirebase/Firestore 找不到匹配的索引,但没有创建索引的选项
【发布时间】:2021-09-25 00:05:12
【问题描述】:

我正在尝试在我的应用程序中运行一个 Firestore 查询,该查询引发了一个索引缺失的错误。 Firestore 过去总是包含一个链接来单击控制台以创建丢失的索引,但这次它不存在所以我被卡住了! 不知道这次我做了什么不同的事情。

这是控制台错误:

prebuilt-d16b955d-cdb9e87f.js:188 Uncaught (in promise) FirebaseError: no matching index found.
at new e (prebuilt-d16b955d-cdb9e87f.js:188)
at prebuilt-d16b955d-cdb9e87f.js:10416
at prebuilt-d16b955d-cdb9e87f.js:10414
at e.onMessage (prebuilt-d16b955d-cdb9e87f.js:10403)
at prebuilt-d16b955d-cdb9e87f.js:10356
at prebuilt-d16b955d-cdb9e87f.js:10387
at prebuilt-d16b955d-cdb9e87f.js:15180

这是我的 JS 函数:

loadcatalogues() {
      console.log(this.clubID);
      this.showspinner = true;
      this.catalogues = [];
      var today = moment().utc().unix();
      let self = this;
      fb.catalogueCollection
        .where("clubID", "==", this.clubID)
        .where("expiry", ">", today)
        .orderBy("expiry", "asc")
        .orderBy("price", "asc")
        .get()
        .then(function (querySnapshot) {
          querySnapshot.forEach(function (doc) {
            if (
              doc.data().members &&
              doc.data().members.indexOf(self.userProfile.id) !== -1
            ) {
              return false;
            }
            var starttime = moment.unix(doc.data().start).utc();
            var endtime = moment.unix(doc.data().expiry).utc();
            var tempdata = {
              title: doc.data().title,
              description: doc.data().description,
              start: starttime.format("DD-MM-YYYY"),
              expiry: endtime.format("DD-MM-YYYY"),
              price: doc.data().price,
              purchased: false,
              stripeid: doc.data().stripeid,
              catalogueid: doc.id,
              limited: doc.data().limited,
            };
            self.catalogues.push(tempdata);
          });
          if (self.catalogues.length == 0) {
            self.shownooptions = true;
          }
          self.showspinner = false;
        });
    },

如果我删除第一个 where 子句 (.where("clubID", "==", this.clubID)) 则查询运行良好,所以我猜测该查询已经存在索引。 我最近才添加了 clubID 字段,所以会不会缺少索引?

谢谢!!

【问题讨论】:

  • 索引是long-running operation,这意味着它可能需要一段时间才能完成。该字段可能尚未编入索引。您可以尝试使用gcloud firestore operations list 查找正在进行的索引操作。另外,您是否在 Firestore 模式下使用 Datastore?如果是这样,这个线程可能会有所帮助:“no matching index found” Google Cloud Firestore Datastore library
  • 感谢 Farid - 我已经检查了 gcloud firestore 操作列表,没有任何明显的迹象可以显示长时间运行的索引操作。我使用的是 Firestore Native 而不是 Datastore 模式。直到最近才出现这种情况,这就是它如此奇怪的原因。

标签: firebase vue.js indexing google-cloud-firestore


【解决方案1】:

Google Firestore 目前似乎存在问题。 拨打了支持电话,他们已确认已收到其他几份有关此问题的报告,并且他们的工程团队正在调查。

【讨论】:

  • 作为一项更新 - 这已由 Google 回滚更改修复 - 现在一切正常!
猜你喜欢
  • 2019-01-14
  • 1970-01-01
  • 1970-01-01
  • 2014-03-24
  • 2021-05-14
  • 1970-01-01
  • 2021-02-21
  • 2020-08-16
  • 2018-11-23
相关资源
最近更新 更多