B.E*_*.E. 1 python google-app-engine google-cloud-datastore
我使用以下类来存储一些数据:
class NewsArticle(db.Model):
score = db.FloatProperty(default=0.0)
date_scored = db.DateTimeProperty()
...
Run Code Online (Sandbox Code Playgroud)
我需要做的是让那些在某个时间段内获得最高分的NewsArticle实体(例如获得今天或上周的最高得分数据实体).
我尝试了以下方法:
query = db.GqlQuery('SELECT * FROM NewsArticle WHERE date_created > DATETIME(:year, :month, :day, 0, 0, 0) ORDER BY score DESC', year=date.selected_year, month=date.selected_month, day=date.selected_day)
Run Code Online (Sandbox Code Playgroud)
但这不起作用,因为数据存储区需要
第一个排序属性必须与不等过滤器属性相同
我考虑将所有NewsArticle实体放在特定的时间范围内,然后在我的应用程序中进行分数排序,但我期待大量的结果,因此内存排序不会有效.
我的问题可能还有哪些其他解决方案?
| 归档时间: |
|
| 查看次数: |
2728 次 |
| 最近记录: |