doushadu0901 2018-07-20 13:44
浏览 32
已采纳

Google App Engine for Golang中将index.yaml导入到哪里?

Playing with Bookshelf tutorial and the Auth package.

The ListBooksCreatedBy query is failing with this error:

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  

However, index.yaml does exist and is in the same directory as app.yaml :
index YAML content:

indexes:   

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

Why would the index not be imported?

Where in the Golang App Engine code is the index.yaml imported?

I searched the src and found nothing.

  • 写回答

1条回答 默认 最新

  • dongpouda6700 2018-07-20 14:33
    关注

    The index.yaml file is not intended to be imported/used in your application code, it is intended to be deployed to the Datastore service (separately/independently from your app deployments!) to configure its indexing activities. From 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.

    Only after proper deployment and, if needed, the completion of the index update operation (i.e. the index reaches the Serving state) the app's queries needing that index can work.

    The index.yaml file is also used by the local development server in its datastore emulation. By default it automatically updates the file with the necessary indexes for the queries it encounters, but the file isn't automatically deployed to the Datastore. But you can disable this behaviour using the --require_indexes option. From 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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥50 STM32单片机传感器读取错误
  • ¥50 power BI 从Mysql服务器导入数据,但连接进去后显示表无数据
  • ¥15 (关键词-阻抗匹配,HFSS,RFID标签)
  • ¥50 sft下载大文阻塞卡死
  • ¥15 机器人轨迹规划相关问题
  • ¥15 word样式右侧翻页键消失
  • ¥15 springboot+vue 集成keycloak sso到阿里云
  • ¥15 win7系统进入桌面过一秒后突然黑屏
  • ¥30 backtrader对于期货交易的现金和资产计算的问题
  • ¥15 求C# .net4.8小报表工具