【发布时间】:2022-02-19 00:16:44
【问题描述】:
我有一种名为“审计”的类型,并且有许多属性,但是我只需要按特定顺序索引某些属性,因为我主要查询:
select DISTINCT ON (traceId) * from audit where tenantId='123'
当我尝试在 GCP 控制台中运行它时,它会引发错误:
GQL Query error: Your Datastore does not have the composite index (developer-supplied) required for this query.
我还尝试从使用 @google-cloud/datastore package 的节点 js 应用程序运行它,并且数据存储区抛出错误:
9 FAILED_PRECONDITION: no matching index found. recommended index is:
- kind: audit
properties:
- name: tenantId
- name: traceId
index.yaml 是使用 terraforms 创建的,内容是:
indexes:
- kind: "audit"
properties:
- name: "tenantId"
- name: "traceId"
# AUTOGENERATED
# This index.yaml is automatically updated whenever the Cloud Datastore
# emulator detects that a new type of query is run. If you want to manage the
# index.yaml file manually, remove the "# AUTOGENERATED" marker line above.
# If you want to manage some indexes manually, move them above the marker line.
使用这个 index.yaml 文件,本地数据存储模拟器可以按预期工作。
在 GCP 控制台中,我看到索引正在设置并处于服务状态。
【问题讨论】:
-
这与 Terraform 有什么关系?
-
@MarkoE 我们已经使用 terraforms 添加了数据存储索引。 github.com/hashicorp/terraform-provider-google/blob/master/…
-
但这个问题与 Terraform 本身无关?
-
我查看了本地生成的索引,没有一个在引号中包含
kind或properties。尝试删除您的引号,即使用audit而不是"audit";属性也是一样的。重新部署您的index.yaml文件并确保将其设置为服务状态。看看能不能解决你的问题 -
@NoCommandLine 它也适用于引号。我已经测试过了,它运行良好,没有任何问题。
标签: node.js google-cloud-platform terraform google-cloud-datastore gql