【问题标题】:how to deal with datastore-indexes app engine?如何处理数据存储索引应用程序引擎?
【发布时间】:2012-07-17 09:35:02
【问题描述】:

对于这个例子 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 错误验证

那么我怎样才能得到这些索引呢?

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

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

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

【问题讨论】:

  • 你错过了关闭。
  • 我加了,还是一样的问题
  • 转到管理控制台的“数据存储索引”部分,检查相关索引是否实际上正在“服务”。

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


【解决方案1】:

您最好的做法是在本地运行您的应用并对这些实体执行一些测试查询。 由于您的索引配置中有&lt;datastore-indexes autoGenerate="true"&gt;,您应该得到一个名为

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

您应该在其中获取应用运行所需的所有索引定义。

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

如果您转到云控制台并检查您的存储/数据存储/索引视图,那么您应该是所有索引的构建或服务。一旦所有这些索引都处于“服务”状态,您就可以开始了。

【讨论】:

    猜你喜欢
    • 2012-11-10
    • 1970-01-01
    • 1970-01-01
    • 2014-10-21
    • 1970-01-01
    • 1970-01-01
    • 2016-07-14
    • 1970-01-01
    相关资源
    最近更新 更多