因此,我尝试在 Google Cloud 数据存储上运行查询,如下所示:
let query = datastore.createQuery(dataType)
.select(["id", "version", "lm", "name"])
.filter("owner", "=", request.params.owner)
.filter("lm", ">=", request.query.date_start)
.groupBy(["lm"])
.order("lm")
但是我遇到了一个错误,指出
no matching index found. recommended index is:
- kind: Entry
properties:
- name: lm
- name: id
- name: name
- name: version
当我使用 id
而不是 lm
对所有方法运行查询时,我没有遇到任何错误。
这是因为在我的 index.yaml
文件中我有这样的索引:?
- kind: Entry
properties:
- name: id
- name: version
- name: lm
- name: name
我真的必须按照建议的顺序创建一个新索引吗?或者有什么方法可以做到这一点而无需创建另一个索引?谢谢!
最佳答案
是的,您需要创建一个新索引,您显示的现有索引不等效,因此它不能用于您的查询 - 属性顺序很重要(至少对于不等式)过滤和排序)。查看相关Google Datastore Composite index issue
关于node.js - 错误: FAILED_PRECONDITION: no matching index found.推荐索引为:,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51217563/