ofy() appengine 日期搜索查询
ofy() appengine Date search query
我想搜索两个日期之间的员工列表,即。 2014 年 1 月 1 日至 2014 年 12 月 31 日使用 GAE ofy(objectify) 进行 branch.How 我会这样做吗?
ulist=ofy().load().type(Employee.class).filter("branch", branch).filter("date >=", fromdate).filter("date <=", toDate).list();
有2个字段
-Branch 是自动生成的字段。
-对于日期,我采用了 2 个日期框、fromDate 和 toDate,并使用这 2 个日期我必须在日期字段上查询。
上面写的查询不起作用并且在日期之间搜索时没有给出结果。但是,如果在起始日期和截止日期中都输入了相同的日期,那么它的工作。
我的逻辑是否有任何问题,或者是否有任何其他方法可以用来找出在两个日期之间加入的分支机构的员工?
您需要指定一个自定义索引来支持此查询,因为它结合了不同属性的多个过滤器。
根据 documentation:
Other forms of query require their indexes to be specified in the index configuration file, including:
...
Queries with one or more inequality filters on a property and one or more equality filters on other properties
...
您的查询有一个等式过滤器(在 branch
上)和两个不等式(在 date
上)过滤器。
documentation 告诉您有关配置自定义索引的所有信息。
我想搜索两个日期之间的员工列表,即。 2014 年 1 月 1 日至 2014 年 12 月 31 日使用 GAE ofy(objectify) 进行 branch.How 我会这样做吗?
ulist=ofy().load().type(Employee.class).filter("branch", branch).filter("date >=", fromdate).filter("date <=", toDate).list();
有2个字段 -Branch 是自动生成的字段。 -对于日期,我采用了 2 个日期框、fromDate 和 toDate,并使用这 2 个日期我必须在日期字段上查询。
上面写的查询不起作用并且在日期之间搜索时没有给出结果。但是,如果在起始日期和截止日期中都输入了相同的日期,那么它的工作。
我的逻辑是否有任何问题,或者是否有任何其他方法可以用来找出在两个日期之间加入的分支机构的员工?
您需要指定一个自定义索引来支持此查询,因为它结合了不同属性的多个过滤器。
根据 documentation:
Other forms of query require their indexes to be specified in the index configuration file, including:
...
Queries with one or more inequality filters on a property and one or more equality filters on other properties
...
您的查询有一个等式过滤器(在 branch
上)和两个不等式(在 date
上)过滤器。
documentation 告诉您有关配置自定义索引的所有信息。