找不到匹配的索引

找不到匹配的索引

本文介绍了Google App Engine 错误:NeedIndexError:找不到匹配的索引的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用 Google 的应用引擎索引时遇到问题.通过 GoogleAppEngineLauncher 运行我的应用程序时,该应用程序运行良好.部署应用程序时,我收到以下错误:

I'm having trouble with Google's App engine indexes. When running my app via the GoogleAppEngineLauncher, the app is working fine. When deploying the app, I get the following error:

NeedIndexError: no matching index found.
The suggested index for this query is:
- kind: Bar
  ancestor: yes
  properties:
  - name: rating
    direction: desc

在这行代码之后产生的错误:

The error is generated after this line of code:

 bars = bar_query.fetch(10)

在上面这行代码之前,它是:

Before the above line of code, it reads:

bar_query = Bar.query(ancestor=guestbook_key(guestbook_name)).order(-Bar.rating)

我的 index.yaml 文件包含以下 # AUTOGENERATED: 的确切建议"索引:

My index.yaml file contains the exact "suggested" index below # AUTOGENERATED:

- kind: Bar
  ancestor: yes
  properties:
  - name: rating
    direction: desc

我可能遗漏了什么吗?我删除了 index.yaml 文件并再次部署了该应用程序(通过命令行)并且少了一个文件上传 - 所以 index.yaml 文件就在那里.

Am I maybe missing something? I removed the index.yaml file and deployed the app again (via the command-line) and one less file was uploaded - so the index.yaml file is there.

本地一切正常.我正在使用最新的 Mac OSx.用于部署的命令是:

Everything is working fine locally. I'm working on the latest Mac OSx. The command used for deployment was:

appcfg.py -A app-name --oauth2 update app

我实现的数据存储大致基于留言簿教程应用.

The datastore I implemented is loosely based on the guestbook tutorial app.

任何帮助将不胜感激.

我的 ndb.Model 定义如下:

My ndb.Model is defined as follow:

class Bar(ndb.Model):
    content = ndb.StringProperty(indexed=False)
    lat = ndb.FloatProperty(indexed=False)
    lon = ndb.FloatProperty(indexed=False)
    rating = ndb.IntegerProperty(indexed=True)
    url = ndb.TextProperty(indexed=False)

推荐答案

检查 https://appengine.google.com/datastore/index 以查看此索引是否存在并且状态设置为正在服务".可能索引还在构建中.

Check https://appengine.google.com/datastore/indexes to see if this index is present and status set to "serving". It's possible that the index is still being built.

开发环境模拟生产环境.它实际上没有数据存储区意义上的索引.

The development environment emulates the production environment. It does not really have indexes in the Datastore sense.

这篇关于Google App Engine 错误:NeedIndexError:找不到匹配的索引的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-15 00:26