简体   繁体   English

对Google App Engine进行排序

[英]Sort Google App Engine

I wish to get a list of Appointments from GAE under a specific Merchant and sort according the the date time it was made ( dateLog ): 我希望从特定Merchant获得GAE的约会列表,并根据约会的日期时间进行排序( dateLog ):

PersistenceManager pm = PMF.get().getPersistenceManager();
String query = "select from " + Appointment.class.getName();  
query += " where merchant == '" + session.getAttribute("merchant") + "'";
query += " order by dateLog desc range 0,5";
List<Appointment> appointment = (List<Appointment>) pm.newQuery(query).execute(); 

However, it returns the error, and I have checked / double checked many times to no avail. 但是,它返回错误,并且我已经检查/多次检查多次,但无济于事。 Anyone can help? 有人可以帮忙吗? I'm stumped. 我很沮丧

You should specify the suggested index for datastore in WEB-INF/datastore-indexes.xml , in your app's war/ directory. 您应该在应用程序war/目录的WEB-INF/datastore-indexes.xml为数据存储指定建议的索引。 The XML looks like this: XML如下所示:

<?xml version="1.0" encoding="utf-8"?>
<datastore-indexes  autoGenerate="true">
  <datastore-index kind="Appointment" ancestor="false" source="manual">
    <property name="merchant" direction="asc"/> 
    <property name="dateLog" direction="desc"/> 
  </datastore-index>
</datastore-indexes>

Reference: https://developers.google.com/appengine/docs/java/config/indexconfig 参考: https : //developers.google.com/appengine/docs/java/config/indexconfig

If you test the URL before uploading to App engine server, then Index file will be auto generated. 如果您在上传到App Engine服务器之前测试了网址,则索引文件将自动生成。 Run in development server and hit the URL which shows you the error, It will generate the File and when you deploy to App engine server, Indexes will be build and one more thing, It will take time you can see that in Datastore Indexes (Building and Serving) in the Google App Engine Admin Console. 在开发服务器中运行并点击显示错误的URL,它将生成文件,当您将其部署到App Engine服务器时,将建立索引,还有另一件事,这需要一些时间,您才能在Datastore Indexes(构建和服务)在Google App Engine管理控制台中。

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

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