4

對於這個例子 LINK 我試圖做到這一點,但這種異常發生?如何處理數據存儲索引應用程序引擎?

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

我該如何手動編寫這些索引?我儘量讓WEB-INF /數據存儲,indexes.xml 在這個XML我寫:

<?xml version="1.0" encoding="utf-8"?> 
<datastore-indexes autoGenerate="true"> 

<datastore-index kind="Contact" ancestor="true" source="manual"> 
    <property name="UserContacts_INTEGER_IDX" direction="asc"/> 
</datastore-index> 

,但是當我要多多部署此錯誤阻止我繼續部署

在「將商店部署到Google」期間發生內部錯誤。 驗證XML錯誤

那麼我怎樣才能得到這些索引?

另一個問題>> 當我運行該代碼,並添加在用戶類的一些屬性

@Persistent (mappedBy = "userC") 
public List<Contact> UserContacts =new ArrayList<Contact>(); 

和部署,發動機使但是對於UserContacts指標出現異常,由於新的屬性 - 上面的同樣的錯誤不能使索引給他們 -

+0

您錯過了關閉。 – 2012-07-17 16:42:07

+0

我添加了它,但仍然是同樣的問題 – Start 2012-07-17 17:53:47

+0

轉到管理控制檯的「數據存儲索引」部分,並檢查相關索引是否實際上是「正在服務」。 – 2012-07-19 07:44:10

回答

1

你最好的辦法是在本地運行你的應用程序,並對這些實體執行一些測試查詢。 當你有<datastore-indexes autoGenerate="true">在你的索引的配置,你應該得到一個文件在那裏叫

WEB-INF/appengine-generated/datastore-indexes-auto.xml 

你應該得到所有需要爲您的應用程序工作的索引定義。

將這些索引定義複製到WEB-INF/datastore-indexes.xml並更新您的應用程序。

如果你去你的雲控制檯並檢查你的存儲/數據存儲/索引視圖,你應該是建立或服務的索引。一旦所有這些指標都處於「服務」狀態,您應該很樂意去。

相關問題