swift - 查询需要一个索引。你可以在这里创建它 : {link is broken}

标签 swift google-cloud-firestore firebase-console

我正在查询我的“GroupConvos”集合,其中所有文档都有一个 memberIds字符串数组,包含关于属于该组的成员的 ID,并对 GroupConvos 执行以下查询给我一个损坏的链接

self.db.collection(kGroupConvos)
       .order(by: kUpdatedAt, descending: true)
       .whereField("memberIds", arrayContains: self.currentUserId)
       .limit(to: 20)
       .getDocuments { [weak self] snapshot, error in
            if let error = error {
               print(error) 
            } else { ... }

The query requires an index. You can create it here: {link}

图片:

enter image description here

所以我进入控制台并创建了一个索引:

enter image description here

而且我在查询时不断收到同样的错误。关于在这里做什么有什么建议吗?

最佳答案

如果您使用数组包含来搜索字段,看起来您需要向其添加数组包含类型索引:

enter image description here

请注意,您有一个选项。看起来您所做的是使 memberIds 成为升序类型的字段索引。

关于swift - 查询需要一个索引。你可以在这里创建它 : {link is broken},我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53401144/

相关文章:

unit-testing - 如何使用 JUnit 在 android 中对 Firestore 进行单元测试?

android - Firebase 实时数据库与 Cloud Firestore 的区别

firebase - 重置 Firebase 密码重置的操作网址

Firebase 最大项目和应用程序

ios - 为要在 Swift 中使用的 Objective-C 类添加便利初始化程序扩展

ios - 使用框架!和模型未找到构建错误

firebase - 关于Firebase读写

firebase - 当控制台打开一段时间时,Cloud Firestore 上出现 "Error loading documents"

ios - 在详细信息标题栏中,显示 “Picture X of Y”

ios - Swift 中的时间戳