查询/ GqlQuery .order()限制的结果集?
-
18-09-2019 - |
题
我只注意到从一个查询,我有麻烦了解一个奇怪的结果。看起来好像添加顺序()来查询限制了结果我回来
下面是我的相互作用:
>>> SomeModel.all().filter('action =', 'foo').order('created_at').count(),
SomeModel.all().filter('action =', 'foo').count()
(192L, 293L)
>>> SomeModel.all().filter('action =', 'foo').order('created_at').count(),
SomeModel.all().filter('action =', 'foo').count()
(193L, 294L)
正如你所看到的,并没有这两个查询之间增加了一百实体。这似乎是为了()指令限制的结果集。但created_at
是必需的属性和存在于所有实体。
>>> count = 0
>>> for entity in SomeModel.all().filter('action =', 'foo'):
... if not entity.created_at:
... raise Exception, 'Not found!'
... count += 1
...
>>> print count
361
没有异常。那么,为什么会与ORDER不会返回所有实体的查询?
最后,调查是否是坏数据:
>>> print "ascending=%d no-filter=%d descending=%d" % (
SomeModel.all().filter('action =', 'foo').order('created_at').count(),
SomeModel.all().filter('action =', 'foo').count(),
SomeModel.all().filter('action =', 'foo').order('-created_at').count())
ascending=79 no-filter=179 descending=173
解决方案
这个问题已经消失,尽管没有改变我的代码。最合理的猜测我是,也许指数下跌的背后,虽然我曾以为,如果我得到的put(成功返回),则更新索引。
不隶属于 StackOverflow