用户工具

站点工具


google:gae:index-error

GAE索引出错解决方法:no matching index found. This query needs this index

Google AppEngine is really cool. You can host your app in few steps, easy to setup, free, and allows you to develop web applications using Python, Django and Google Datastore.

I’ve played a while with AppEngine, helping another projects, setting up my stuff there and got lots of tricks to help another users. Today (March 31, 2009) I faced a small problem, related to index.

I was executing a query on my website, and got an error: no matching index found. This query needs this index - kind: Comments properties: – name: page – name: data_issued direction: desc.

What went wrong ? Appengine tries to make everything for you, but depending on the way you execute the Gql, you need to edit index.yaml adding some information to make it work. The query which I was executing is something like: db.GqlQuery(“SELECT * from Comments where page=:1 order by date_issued”). Since I don’t have any index which matches with the filter page=something, order by date, it gives me an error.

To fix, just edit index.yaml, adding:

- kind: Comments
properties:
- name: page
- name: data_issued
direction: desc

After that, resync the index, using:

appcfg.py update_indexes .

Now you’ll be able to run your query

参考

google/gae/index-error.txt · 最后更改: 2011/03/16 10:00 (外部编辑)