[英]DatastoreNeedIndexException: no matching index found. Using Objectify
Having this error after deploying my code to cloud, using google appengine, i use objectify indexing for my filtering. 使用Google Appengine将代码部署到云后,出现此错误,我使用对象化索引进行过滤。
here is my java class (Entity) file containing the index 这是我的包含索引的java类(实体)文件
@Entity
public class Session{
@Index private Integer year;
@Index private Key<Institute> institute;
//some other manipulation goes below
}
When am trying to call a list of entity from datastore using objectify like this 当试图像这样使用objectify从数据存储中调用实体列表时
ofy().load().type(Session.class).filter("institute",t).order("year").list();//order by year
it throws the below error on my console , the below image shows it , sorry not too clear 它在我的控制台上抛出以下错误,下图显示了它,对不起不太清楚
You need to add suggested index definition to your datastore-indexes.xml
file. 您需要将建议的索引定义添加到
datastore-indexes.xml
文件中。 If you don't have this file, you need to create it in /war/WEB-INF/ folder: 如果没有此文件,则需要在/ 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>
Note that most index definitions can be auto-genereated when you test your app on the development server, but sometimes it's not easy to test every possible use case and manual definitions may be an easier option. 请注意,当您在开发服务器上测试应用程序时,大多数索引定义都可以自动生成,但是有时测试每个可能的用例并不容易,手动定义可能更容易。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.