如何处理数据存储索引应用引擎?

时间:2012-07-17 09:35:02

标签: google-app-engine servlets jdo google-cloud-datastore datanucleus

这个例子 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 / datastore-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错误

那我怎么能得到这些指数?

其他问题&gt;&gt;  当我运行此代码并在User类中添加一些属性

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

并部署它,引擎为UserContacts创建索引然而由于新属性而出现异常 - 上面的相同错误无法为它们制作索引 -

1 个答案:

答案 0 :(得分:1)

您要做的最好的事情是在本地运行应用程序并对这些实体执行一些测试查询。 在索引配置中有<datastore-indexes autoGenerate="true">时,您应该得到一个名为

的文件
WEB-INF/appengine-generated/datastore-indexes-auto.xml 

在那里,您应该获得应用程序运行所需的所有索引定义。

将这些索引定义复制到WEB-INF/datastore-indexes.xml并更新您的应用。

如果您转到云控制台并检查存储/数据存储区/索引视图,那么您应该将所有建立或服务的索引编入索引。一旦所有这些索引都在“服务”,你就应该好好去。