简体   繁体   English

删除 Google Cloud Datastore 索引

[英]Google Cloud Datastore index removal

I have few Google Datastore indexes I've added few months.我添加了几个月的 Google Datastore 索引很少。 Today I added another one.今天我又加了一个。 After few minutes, I found that this is not the right index that I have to create.几分钟后,我发现这不是我必须创建的正确索引。

I called this:我这样称呼:

$ 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
---
...

And located the index to be removed (ID= XXX2 ).并找到要删除的索引 (ID= XXX2 )。

I found the cleanup command description and it's not clear to me.我找到了清理命令描述,但我不清楚。 This function is asking to provide index.yaml file.此 function 要求提供index.yaml文件。

What should be found in this file?应该在这个文件中找到什么?

  1. List of indexes to be kept.要保留的索引列表。 All the indexes that not exists in this file will be removed.该文件中不存在的所有索引都将被删除。
  2. List of indexes to be removed.要删除的索引列表。

If your answer is going to be 1 (List of indexes to be kept) - How I can generate a yaml file from my existing indexes?如果您的答案是 1(要保留的索引列表)-我如何从现有索引生成yaml文件? Its needed because I don't have those index definitions locally.它是必需的,因为我在本地没有那些索引定义。 Needed something like:需要类似的东西:

gcloud datastore indexes list --export=yaml

According to public documentation the command will remove any indexes that exist that are not included in the index.yaml file.根据公开文档,该命令将删除 index.yaml 文件中未包含的所有索引。 Therefore in the index.yaml file be sure to only include the indexes that you are actively using.因此在 index.yaml 文件中确保只包含您正在使用的索引。

As I am aware, there seems to be no particular means to generate a new index.yaml file, however, it seems that the best course of action would be to attempt to export the output of the command used:据我所知,似乎没有特别的方法来生成新的 index.yaml 文件,但是,似乎最好的做法是尝试导出所用命令的输出:

    gcloud datastore indexes list > index.yaml

(Alter the command to meet your CLI's needs) (更改命令以满足您的 CLI 需求)

And proceed to format it appropriately using the provided example as guidance.并继续使用提供的示例作为指导对其进行适当的格式化

You can generate the properly formatted index.yaml file by using the following script.您可以使用以下脚本生成格式正确的 index.yaml 文件。 https://github.com/ArunMuthuram/gcpDatastoreIndexYamlGenerator Once the index.yaml is generated, go through and remove the composite indexes that are not required anymore. https://github.com/ArunMuthuram/gcpDatastoreIndexYamlGenerator一旦 index.yaml 生成,go 不再需要复合索引。 Use the modified index.yaml in the cleanup command.在清理命令中使用修改后的 index.yaml。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM