【问题标题】:Google Cloud Datastore Index not found even if it is set即使设置了 Google Cloud Datastore Index 也找不到
【发布时间】: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 本身无关?
  • 我查看了本地生成的索引,没有一个在引号中包含 kindproperties。尝试删除您的引号,即使用audit 而不是"audit";属性也是一样的。重新部署您的 index.yaml 文件并确保将其设置为服务状态。看看能不能解决你的问题
  • @NoCommandLine 它也适用于引号。我已经测试过了,它运行良好,没有任何问题。

标签: node.js google-cloud-platform terraform google-cloud-datastore gql


【解决方案1】:

您在 index.yaml 文件中的 Datastore 属性名称周围似乎有额外的引号 "

indexes:

- kind: Cat
  properties:
  - name: name
  - name: age

正确语法请参考documentation

在 Google Provider Terraform 方面,有一个 ~> Warning 提到,确保按照它创建兼容的数据库类型。有关兼容性设置的更多详细信息,请参阅here

【讨论】:

    猜你喜欢
    • 2011-12-06
    • 2013-11-02
    • 2023-03-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-01-19
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多