【问题标题】:Google Cloud Datastore index removal删除 Google Cloud Datastore 索引
【发布时间】:2021-01-13 04:44:05
【问题描述】:

我添加了几个月的 Google Datastore 索引很少。今天我又加了一个。几分钟后,我发现这不是我必须创建的正确索引。

我称之为:

$ gcloud datastore indexes list
---
ancestor: NONE
indexId: XXX1
kind: ThisIsKindName
projectId: GCP-PROJ-ID
properties:
- direction: ASCENDING
  name: QueueName
- direction: ASCENDING
  name: ExecutionLength
state: READY
---
ancestor: NONE
indexId: XXX2
kind: ThisIsKindName
projectId: GCP-PROJ-ID
properties:
- direction: ASCENDING
  name: labels.application
- direction: DESCENDING
  name: ExecutionLength
state: READY
---
...

并定位到要移除的索引(ID=XXX2)。

我找到了cleanup 命令描述,但我不清楚。此函数要求提供index.yaml 文件。

应该在这个文件中找到什么?

  1. 要保留的索引列表。此文件中不存在的所有索引都将被删除。
  2. 要删除的索引列表。

如果您的答案是 1(要保留的索引列表) - 我如何从现有索引生成 yaml 文件?它是必需的,因为我在本地没有那些索引定义。需要类似的东西:

gcloud datastore indexes list --export=yaml

【问题讨论】:

    标签: google-cloud-platform google-cloud-datastore


    【解决方案1】:

    根据public documentation,该命令将删除未包含在 index.yaml 文件中的所有索引。因此,请确保在 index.yaml 文件中仅包含您正在使用的索引。

    据我所知,似乎没有特别的方法可以生成新的 index.yaml 文件,但是,最好的做法似乎是尝试导出所用命令的输出:

        gcloud datastore indexes list > index.yaml
    

    (更改命令以满足 CLI 的需求)

    然后使用提供的example 作为指导,适当地转到format

    【讨论】:

    • 我担心这会是答案。我觉得要删除索引很难走。谢谢!
    • 别担心,我很高兴能帮上忙!
    猜你喜欢
    • 2018-07-16
    • 2020-01-22
    • 1970-01-01
    • 1970-01-01
    • 2020-09-06
    • 1970-01-01
    • 1970-01-01
    • 2020-08-19
    • 1970-01-01
    相关资源
    最近更新 更多