Google App Engine error: NeedIndexError: no matching index found

ISJ picture ISJ · Apr 22, 2015 · Viewed 10.7k times · Source

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)

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

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

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.

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.

Any help would be greatly appreciated.

EDIT:

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)

Answer

Andrei Volgin picture Andrei Volgin · Apr 22, 2015

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.