gpt4 book ai didi

google-app-engine - Google App Engine for Golang 中的 index.yaml 在哪里导入?

转载 作者:IT王子 更新时间:2023-10-29 02:37:16 24 4
gpt4 key购买 nike

使用 Bookshelf 教程和 Auth 包。

ListBooksCreatedBy 查询失败并出现此错误:

could not list books: datastoredb: could not list books: rpc error: code = FailedPrecondition desc = no matching index found. recommended index is:   
- kind: Book
properties:
- name: CreatedByID
- name: Title

但是,index.yaml 确实存在并且与 app.yaml 在同一目录中:
索引 YAML 内容:

indexes:   

# This index enables filtering by "CreatedByID" and sort by "Title".
- kind: Book
properties:
- name: CreatedByID
direction: asc
- name: Title
direction: asc

为什么不导入索引?

index.yaml 在 Golang App Engine 代码中的什么地方导入?

我搜索了 src,什么也没找到。

最佳答案

index.yaml 文件不打算在您的应用程序代码中导入/使用,它旨在部署到数据存储服务(与您的应用程序部署分开/独立!)以配置它的索引事件。来自 Updating indexes :

You upload your index.yaml configuration file to Cloud Datastore with the gcloud command. If the index.yaml file defines any indexes that don't exist in Cloud Datastore, those new indexes are built.

It can take a while for Cloud Datastore to create all the indexes and therefore, those indexes won't be immediately available to App Engine. If your app is already configured to receive traffic, then exceptions can occur for queries that require an index that is still in the process of being built.

To avoid exceptions, you must allow time for all the indexes to build.

只有在正确部署并在需要时完成索引更新操作(即索引达到 Serving 状态)之后,需要该索引的应用查询才能工作。

index.yaml 文件也被本地开发服务器用于其数据存储模拟。默认情况下,它会自动使用遇到的查询所需的索引更新文件,但文件不会自动部署到数据存储区。但是您可以使用 --require_indexes 选项禁用此行为。来自 Local Development Server Options :

--require_indexes=yes|no

Disables automatic generation of entries in the index.yaml file. Instead, when the application makes a query that requires that its index be defined in the file and the index definition is not found, an exception will be raised, similar to what would happen when running on App Engine. The default value is no.

关于google-app-engine - Google App Engine for Golang 中的 index.yaml 在哪里导入?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51443952/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com