简体   繁体   English

Google App Engine中的订购结果

[英]Ordering results in google app engine

Iam trying to make a simple ordering using objectify and GAE. Iam尝试使用objectify和GAE进行简单的订购。 Unfortunatly it does't work. 不幸的是,它不起作用。 here is a simple example 这是一个简单的例子

class Book{  
     int publishYear;  
     long price;  
}

According to google, you have to order the field that you made your inequality filtering on it. 根据google的说法,您必须订购对其进行不等式过滤的字段。 so i did the following 所以我做了以下

query.filter("publishYear >=", year)  
query.order("publishYear")

then i want to order with price so i added the line 然后我想订购价格,所以我添加了这条线

query.order("price")

but nothing is happening. 但是什么也没发生。 I tried on different fields, it seems you can make only one order per query. 我在不同的字段上尝试过,看来每个查询只能下一个订单。 Although this example says something different 虽然这个例子说的有些不同

http://code.google.com/appengine/docs/java/datastore/queries.html#Restrictions_on_Queries http://code.google.com/appengine/docs/java/datastore/queries.html#Restrictions_on_Queries

Anybody has a clue? 有人知道吗? thanks in advance 提前致谢

The Objectify documentation says: Objectify文档说:

To run queries by filtering or sorting against multiple properties (that is, if it can't be satisfied by a zigzag merge on single-property indexes), you must create a multi-value index in your datastore-indexes.xml. 要通过对多个属性进行过滤或排序来运行查询(也就是说,如果单属性索引无法通过之字形合并来满足),则必须在datastore-indexes.xml中创建一个多值索引。 There is a great deal written on this subject; 关于这个主题有很多著作。 we recommend How Entities and Indexes are Stored and Index Building . 我们建议如何存储实体和索引以及如何 建立索引

Hope it will helps. 希望它会有所帮助。

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

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