查询需要一个索引。您可以在这里创建它:{link is broken}
The query requires an index. You can create it here: {link is broken}
我正在查询我的 "GroupConvos" 集合,其中所有文档都有一个 memberIds
字符串数组,其中包含关于属于该组的成员的 ID,并对 GroupConvos
执行以下查询给我一个坏掉的 link
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}
图片:
所以我进入控制台并创建了一个索引:
我在查询时不断收到同样的错误。关于在这里做什么有什么建议吗?
如果您使用 array-contains 来搜索字段,您似乎需要向其添加 Array Contains 类型索引:
请注意,您有一个选项。看起来您所做的是使 memberIds 成为升序类型的字段索引。
对于任何感兴趣的人,防止此查询出现索引错误的正确索引是:
arrayField: arrayContains
更新时间:降序
我正在查询我的 "GroupConvos" 集合,其中所有文档都有一个 memberIds
字符串数组,其中包含关于属于该组的成员的 ID,并对 GroupConvos
执行以下查询给我一个坏掉的 link
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}
图片:
所以我进入控制台并创建了一个索引:
我在查询时不断收到同样的错误。关于在这里做什么有什么建议吗?
如果您使用 array-contains 来搜索字段,您似乎需要向其添加 Array Contains 类型索引:
请注意,您有一个选项。看起来您所做的是使 memberIds 成为升序类型的字段索引。
对于任何感兴趣的人,防止此查询出现索引错误的正确索引是:
arrayField: arrayContains 更新时间:降序