DatastoreNeedIndexException even after defining the index

最后都变了- 提交于 2019-12-11 05:34:20

问题


I am baffled with a problem with my DataStore query on GAE java -- it always complain that I don't have a matching index, even though I have the exact index they suggested in my datastore-indexes.xml -- can something shed some light before I pull all my hair out?

com.google.appengine.api.datastore.DatastoreNeedIndexException: no matching index found.
The suggested index for this query is:
    <datastore-index kind="Users" ancestor="false" source="manual">
        <property name="BILLING_ENABLED" direction="asc"/>
        <property name="EXPIRED" direction="asc"/>
        <property name="api" direction="asc"/>
        <property name="CREATION" direction="asc"/>
    </datastore-index>

My datastore-indexes.xml

<datastore-indexes autoGenerate="true">
    <datastore-index kind="Users" ancestor="false" source="manual">
    <property name="BILLING_ENABLED" direction="asc"/>
    <property name="EXPIRED_DATE" direction="asc"/>
    <property name="EXPIRED" direction="asc"/>
    <property name="api" direction="asc"/>
    <property name="CREATION" direction="asc"/>
    </datastore-index>
</datastore-indexes>

My Query:


Query q = new Query("Users");
Filter filter = CompositeFilterOperator.and(new FilterPredicate("api", Query.FilterOperator.EQUAL,
"val"), new FilterPredicate(EXPIRED, Query.FilterOperator.EQUAL, Boolean.FALSE));
filter = CompositeFilterOperator.and(filter, new FilterPredicate("BILLING_ENABLED", Query.FilterOperator.EQUAL, Boolean.FALSE));
filter = CompositeFilterOperator.and(filter, new FilterPredicate("CREATION", Query.FilterOperator.LESS_THAN_OR_EQUAL, cal.getTime()));

If I understand correctly, I need indexes for "api", "EXPIRED", "BILLING_ENABLED", and "CREATION" since these are used in the query -- but is there anything else I need?

Thanks, Adrian


回答1:


The suggested query is a bit different from what you have. It has to match exactly in order for it to work. Just add the suggested one as an extra index as is, redeploy your app and then check from the Datastore Indexes section on the Dashboard of your application if it's there and has the status: Serving.



来源:https://stackoverflow.com/questions/16221414/datastoreneedindexexception-even-after-defining-the-index

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!