如何从 Google Cloud Datastore 索引中删除条目?

How to remove entries from Google Cloud Datastore index?

我使用 https://console.cloud.google.com/datastore/entities/query. However, when I checked indexes they are still remaining and there is no delete button on https://console.cloud.google.com/datastore/indexes 上的删除按钮从 Google 云数据存储中手动删除了所有数据。我尝试使用控制台命令

gcloud datastore cleanup-indexes

但是这个命令没有帮助。

有没有办法清理索引?

您可以在文档中找到有关 Datastore 索引工作流应如何工作的更多详细信息。具体来说,有一个条目解释 how to delete unused indexes and a summary of the workflow of indexes.

总之,要强制删除索引(默认情况下不会自动删除,会保留一段时间以保证性能不受影响),首先要更新本地index.yaml 文件,删除不再需要的索引。然后,你可以使用你共享的指向本地文件的命令,你的索引应该消失:

gcloud datastore cleanup-indexes /path/to/file/index.yaml

gcloud datastore cleanup-indexes /path/to/file/index.yaml

此命令不再有效

gcloud datastore indexes cleanup /path/to/index.yaml

这是新命令

你应该 运行 他们 google cloud console。通常您可以使用 google cloud console 中的 file upload 功能上传 index.yaml 文件。你的文件直接转到 _admin 你可以 cd 到那里打电话,

gcloud datastore indexes cleanup index.yaml

提示

如果您在 java 项目 中使用 datastore,则您有 datastore-indexes.xml 而不是 index.yaml。如果您不知道去哪里找,您可能很难找到 index.yaml 文件。

您只需查看 IDE 中的 deploy console 即可找到 index.yaml 文件的路径。