【问题标题】:Flutter FirebaseFirestore [cloud_firestore/failed-precondition] IssueFlutter FirebaseFirestore [cloud_firestore/failed-precondition] 问题
【发布时间】:2021-07-14 18:23:33
【问题描述】:

我正在尝试在 FirebaseFirestore.instance.collection('collectionName').where('fieldName1', isEqualTo: 'value1').orderBy('fieldName1', descending:true).snapshots() 语句中执行包含 whereorderBy 的查询。我还为上述语句中定义的两个字段创建了一个复合索引。

但是,我收到了这个错误:

[log] [cloud_firestore/failed-precondition] Operation was rejected because the system is not in a state required for the operation's execution. If performing a query, ensure it has been indexed via the Firebase console.

我正在使用

firebase_core: ^1.3.0
cloud_firestore: ^2.3.0

【问题讨论】:

  • 可以分享创建的索引吗?您还在同一字段上使用 where 方法和 orderBy 吗?

标签: firebase flutter google-cloud-firestore


【解决方案1】:

我猜索引可能有问题。我建议您按照以下步骤操作:

  1. 删除索引。
  2. 再次运行该函数。将引发错误。
  3. 使用adb logcat检查日志。
  4. 会出现一些信息以创建适当的索引。

【讨论】:

  • 检查过了。虽然没有链接或关联链接来创建索引。
猜你喜欢
  • 2021-12-22
  • 2019-01-21
  • 2015-06-02
  • 1970-01-01
  • 2019-11-09
  • 2021-07-04
  • 1970-01-01
  • 2013-09-13
相关资源
最近更新 更多