1
我用GAE上的Java我的数据存储区查询的问题百思不得其解后指数 - 它总是抱怨我没有匹配的指数,即使我有他们在我的datastore-提出确切的指标indexes.xml - 在我把所有的头发都拉出来之前,可以做点什么?DatastoreNeedIndexException甚至定义
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>
我的数据存储,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>
我的查询:
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”, “已过期”, “BILLING_ENABLED”和“CREATION”,因为这些用在查询中 - 但还有什么我需要的吗?
感谢, 阿德里安
谢谢 - 就是这样!我认为索引中有额外的列是可以的,但显然它必须完全一样。 – 2013-04-26 04:59:21