繁体   English   中英

DatastoreNeedIndexException:找不到匹配的索引。 使用Objectify

[英]DatastoreNeedIndexException: no matching index found. Using Objectify

使用Google Appengine将代码部署到云后,出现此错误,我使用对象化索引进行过滤。

这是我的包含索引的java类(实体)文件

@Entity
public class Session{
   @Index private Integer year;
   @Index private Key<Institute> institute;
  //some other manipulation goes below
   }

当试图像这样使用objectify从数据存储中调用实体列表时

ofy().load().type(Session.class).filter("institute",t).order("year").list();//order by year

它在我的控制台上抛出以下错误,下图显示了它,对不起不太清楚

在此处输入图片说明

您需要将建议的索引定义添加到datastore-indexes.xml文件中。 如果没有此文件,则需要在/ war / WEB-INF /文件夹中创建它:

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

    <datastore-index kind="Session" ancestor="false" source="manual">
        <property name="institute" direction="asc"/>
        <property name="year" direction="asc"/>
    </datastore-index>
</datastore-indexes>

请注意,当您在开发服务器上测试应用程序时,大多数索引定义都可以自动生成,但是有时测试每个可能的用例并不容易,手动定义可能更容易。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM