【问题标题】:GAE Index errorGAE 索引错误
【发布时间】:2015-04-03 14:56:07
【问题描述】:

代码在本地主机上运行良好

但是当我将它上传到 GAE 时,我不断收到错误消息:

NeedIndexError: no matching index found.
The suggested index for this query is:
- kind: DataModel
  properties:
  - name: __key__
    direction: desc

我查到这个错误是因为没有更新索引导致的,所以我等了2天。 但仍然出现错误。

我怀疑我使用了三种不同的命令:

DataModel.query(DataModel.key <= ndb.Key('DataModel',continuity_checked_id)).order(
                -DataModel.key).fetch(2001)

DataModel.query().order(-DataModel.date, -DataModel.times)

DataModel.query(DataModel.key >= ndb.Key("DataModel", last_checked_DataModel)).order(DataModel.key).fetch()

我该如何解决这个问题??

【问题讨论】:

  • 是您的 datastore-index.xml 中的建议索引吗?
  • 如果你不告诉他们,系统不会生成你的索引。您需要:a)在 devserver 上运行查询,以便它可以在您推送它时生成索引本身,或者 b)将该特定索引添加到您的文件中,以便在推送时进入系统
  • ...您是否在您的开发人员中测试了该查询然后部署?还是您有已部署的版本并且您现在正在尝试 devserver,而不更改之后部署的内容?

标签: python google-app-engine


【解决方案1】:

如错误消息所示,您需要为尝试运行的查询创建索引。参考参考:https://cloud.google.com/appengine/docs/python/config/indexconfig

indexes:

- kind: DataModel
  properties:
  - name: __key__
    direction: desc

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-11-01
    • 2013-09-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-11-23
    相关资源
    最近更新 更多