【发布时间】:2013-12-11 04:34:31
【问题描述】:
我无法使用复合索引搜索实体。我正在使用 Objectify 4。
实体配置:
@Entity
@Unindex
class MyEntity implements Serialiable
{
@Id String id;
String one;
String two;
long three;
}
索引配置:
<datastore-indexes autoGenerate="true">
<datastore-index kind="MyEntity" ancestor="false">
<property name="one" direction="asc" />
<property name="two" direction="desc" />
</datastore-index>
</datastore-indexes>
我看到了DataStore Indexes 中内置的索引。但是,当我使用以下查询进行搜索时,我总是得到空结果。
Objectify ofy = ObjectifyService.ofy();
Query<MyEntity> query = ofy.loader()
.type(MyEntity.class)
.filter("one", "value-one")
.filter("two", "value-two");
List<MyEntity> result = query.list();
response.getWriter().println("Size: " + result.size());
//^^ this is always "0" ^^
我正在使用 HRD。
大家猜猜出了什么问题?顺便说一句,它曾经工作到一段时间……早在上周。现在,它在开发服务器和实际服务器上都不起作用。
【问题讨论】:
-
补充一点,在服务器上运行 GQL 也会返回零结果。
SELECT * FROM MyEntity where one='value-one' and two='value-two'
标签: java google-app-engine objectify google-cloud-datastore