0
votes

I have created a Kind called User in Google App Engine datastore, and I am trying to add an index for this kind.

Firstly, I followed https://cloud.google.com/appengine/docs/standard/java/config/indexconfig to create index by adding datastore-indexes.xml inside war/WEB-INF, but it doesn't work, no index is created after I deploy to app engine.

code in my datastore-indexes.xml:

<?xml version="1.0" encoding="utf-8"?>
<datastore-indexes autoGenerate="false">
    <datastore-index kind="User" ancestor="false" source="manual">
        <property name="area" direction="asc"/>
        <property name="coins_balance" direction="asc"/>
    </datastore-index>
</datastore-indexes>

Then I followed https://cloud.google.com/appengine/docs/standard/python/config/indexref, I created an index.yaml and run gcloud app deploy index.yaml, this time index is actually created.

So can anyone help me understand why datastore-indexes.xml in my case doesn't work, thanks.

1
How did you deployed to App Engine? Like appcfg.sh update_indexes path/to/datastore-indexes.xml? Because if you don't explicitly/manually deploy this file, as you later did, it won't have any effect. - amport
I see, but I don't have appcfg.sh, only got gcloud, so I guess I'll stick with index.yaml - WANG
Yeah, if you use gcloud instead of appcfg, stick with the yaml format described in here, but the logic to follow is the same, you have to run gcloud app deploy index.yaml for the indexes to deploy. - amport
thank you very much Mangu, issue solved. - WANG

1 Answers

3
votes

As documented in the java index config page and noted in the comments, datastore-indexes.xml is only supported through appcfg.sh at this time. To use gcloud, you'll need to configure your indexes as a yaml file.