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.

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

报告相同问题?

悬赏问题

  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作