2013-04-25 140 views
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」,因爲這些用在查詢中 - 但還有什麼我需要的嗎?

感謝, 阿德里安

回答

2

建議查詢檢索是你有什麼有點不同。它必須完全匹配才能工作。只需添加一個建議作爲額外的索引按原樣重新部署應用,然後從資料儲存庫索引檢查應用程序的儀表板部分,如果它的存在,並具有狀態:服務

+0

謝謝 - 就是這樣!我認爲索引中有額外的列是可以的,但顯然它必須完全一樣。 – 2013-04-26 04:59:21