GAE datastore index not getting created

593 views Asked by At

I'm struggling with the GAE Guestbook demo app. I have made NO modification. I got it running locally, but when I deploy it, I get the following error:

com.google.appengine.api.datastore.DatastoreNeedIndexException: no matching index found. recommended index is:
- kind: Greeting
  ancestor: yes
  properties:
  - name: date
    direction: desc

The suggested index for this query is:
    <datastore-index kind="Greeting" ancestor="true" source="manual">
        <property name="date" direction="desc"/>
    </datastore-index>

When running locally, a datastore-indexes-auto.xml was generated in the target/--SNAPSHOT/WEB-INF/appengine-generated directory. This file contained exactly the required index description:

<datastore-indexes>
  <!-- Used 1 time in query history -->
  <datastore-index kind="Greeting" ancestor="true">
    <property name="date" direction="desc" />
  </datastore-index>
</datastore-indexes>

However, the app throws the error above anyways.

I also tried to move it from the auto generated xml file to the manually xml (datastore-indexes.xml) file.

When I deploy via mvn -e appengine:deploy I get no error or warning:

...
[INFO] GCLOUD: Jan 02, 2017 8:01:14 PM com.google.apphosting.utils.config.IndexesXmlReader readConfigXml
[INFO] GCLOUD: INFO: Successfully processed /Users/stephanhofmann/Projects/mvntestapp/target/mvntestapp-1.0-SNAPSHOT/WEB-INF/datastore-indexes.xml
[INFO] GCLOUD: Jan 02, 2017 8:01:14 PM com.google.apphosting.utils.config.IndexesXmlReader readConfigXml
[INFO] GCLOUD: INFO: Successfully processed /Users/stephanhofmann/Projects/mvntestapp/target/mvntestapp-1.0-SNAPSHOT/WEB-INF/appengine-generated/datastore-indexes-auto.xml
...

Anyways, the Google Developer Console doesn't show any "Composite" Indexes when I check under Datastore > Indexes. I waited for more than 30mins (and there is no data, so indexing should be fast).

Not sure if it is a Composite Index and should show up here, but the App is missing the index and I'm stuck.

Any help is much appreciated.

2

There are 2 answers

0
Þórir Gunnarsson On

Running: gcloud app deploy /Users/stephanhofmann/Projects/mvntestapp/target/mvntestapp-1.0-SNAPSHOT/index.yaml

In a terminal window will define the indexes.

2
DFB On

I was facing the same problem when using mvn appengine:deploy. Then I realized that I had to use mvn appengine:deployIndex explicitly to generate indexes. Hope that helps others.