【发布时间】:2014-12-29 00:08:33
【问题描述】:
我正在尝试使用 Objectify 从数据存储中获取过滤后的列表,但总是返回一个空列表。我尝试添加 @index 并创建一个 datastore-index.xml 文件,但仍然未定义。
我的列表类:
@Entity
@Index
public class Listing {
@Id private Long id;
@Index private double price;
...
我的 API:
@Api(name ="xxxx")
@PersistenceCapable(detachable = "true")
public class ListingServiceAPI {
@ApiMethod(name = "getListings")
public List<Listing> getListings() {
return ofy().load().type(Listing.class).filter("price >", 15).list(); //this fails
//return ofy().load().type(Listing.class).limit(3).list(); //this works
}
}
datastore-indexes.xml:
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<datastore-indexes autoGenerate="true">
<datastore-index kind="Listing" ancestor="false">
<property name="price" direction="asc" />
<property name="category" direction="asc" />
</datastore-index>
</datastore-indexes>
有人知道如何解决此问题以使过滤器查询正常工作吗?
【问题讨论】:
标签: java google-app-engine filter objectify