按GAE的日期(字符串)排序查询结果 [英] Ordering Query results by Date (String) for GAE
问题描述
我在GAE数据存储中存储了数千个实体,其中字段create被保存为日期 String
(标准格式)。
我的问题是,是否仍然可以像这样做 Query
:
Query q = new Query(Post)
.addSort(created,SortDirection.DESCENDING);
其中创建
实际上是一个日期字符串,像这样存储: 2014-12-11T14:31:43 -08:00
并且实际得到降序。结果集是随机的,甚至不按日期排序。
有没有办法调整GAE Query
用这个数据来实现这个目的?
即使GAE将索引日期设置为字符串,因此'2014-12- 11:T14:31:43 -08:00'在'2014-12- 04 T14:31:43 -08:00'后面(例如),这意味着自然排序如果没有,GAE会忽略你在查询中给出的排序顺序。 你有没有索引'created'字段? I have thousands of Entities stored in the GAE datastore where a field "create" is saved as a date My question would be, is it still possible to do a Where " Is there a way to tweak a GAE Even if GAE has indexed date as string so '2014-12-11T14:31:43 -08:00' comes after '2014-12-04T14:31:43 -08:00' (just for example) which means natural sorting order should follow. Have you indexed 'created' field? If not, GAE is gonna ignore the sort order you gave in query. 这篇关于按GAE的日期(字符串)排序查询结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
$ b String
(standard format).Query
like this:Query q = new Query("Post")
.addSort("created", SortDirection.DESCENDING);
created
" is actually a date String, stored like this: 2014-12-11T14:31:43 -08:00"
and actually get a descending order. I've tried it but the result set is just as random and not even in order by date. Query
to achieve this with this data?