DatastoreNeedIndexException:找不到匹配的索引。使用对象化

DatastoreNeedIndexException: no matching index found. Using Objectify

使用 google appengine 将我的代码部署到云后出现此错误,我使用 objectify 索引进行过滤。

这是我的 java class(实体)文件,其中包含索引

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

当我尝试像这样使用对象化从数据存储调用实体列表时

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>

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