DatastoreNeedIndexException甚至在定义索引之后 [英] DatastoreNeedIndexException even after defining the index

查看:114
本文介绍了DatastoreNeedIndexException甚至在定义索引之后的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对GAE java上的DataStore查询存在问题感到困惑 - 它始终抱怨我没有匹配的索引,尽管我的datastore-indexes.xml中提供了他们建议的确切索引 - 可以在我把所有的头发都拉出来之前,有什么东西可以流露出来?

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

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()));

如果我理解正确,我需要索引为api,EXPIRED,BILLING_ENABLED和CREATION 因为这些在查询中使用 - 但有什么我需要的?

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?

谢谢,
Adrian

Thanks, Adrian

推荐答案

建议的查询与您的查询有点不同。它必须完全匹配才能工作。只需按照原样添加建议的额外索引,重新部署您的应用程序,然后从应用程序的仪表板上的数据存储索引部分检查它是否存在并且具有以下状态:服务 strong>。

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.

这篇关于DatastoreNeedIndexException甚至在定义索引之后的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆