如何以编程方式确定哪些 Datastore 索引出错?

How can I programmatically determine which Datastore indexes are in error?

当我在 Google 数据存储上 运行 update_indexes 时,我收到以下消息。它告诉我通过查看GUI来确定哪些索引有误,然后删除这些索引。

我有 200 个错误索引中的 51 个,从 GUI 中复制它们是不可行的。

(编辑:通过费力地从数据存储中删除和添加索引 - indexes.xml,我们确定了一个有问题的索引。)

好的 devops 程序要求我们自动执行此类操作。

如何以编程方式确定哪些索引出错? (Python、bash,甚至 Java 都可以。)

Cannot build indexes that are in state ERROR.To vacuum and rebuild your indexes:
1. Create a backup of your index.yaml specification.
2. Determine the indexes in state ERROR from your admin console: https://appengine.google.com/datastore/indexes?&app_id=s~myproject
3. Remove the definitions of the indexes in ERROR from your index.yaml file.
4. Run "appcfg.py vacuum_indexes your_app_dir/"
5. Wait until the ERROR indexes no longer appear in your admin console.
6. Replace the modified version of your index.yaml file with the original.
7. Run "appcfg.py update_indexes your_app_dir/"

不幸的是,Cloud Datastore 没有用于管理索引的 public API,并且当前的命令行工具使用无法访问该信息的内部 API。

我们的目标是在明年的某个时候进行索引管理 API(已经在进行设计),我将确保我们涵盖这个关键用例。