質問

私はちょうど私が悩みを理解しているクエリから奇妙な結果に気づきました。 はクエリへの順序を()を追加すると、私は戻って取得結果を制限しているかのように表示されます

ここに私の相互作用があります:

>>> 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)

あなたが見ることができるように、百エンティティは2つのクエリの間に追加されませんでした。オーダー()命令は、結果セットを制限しているように思えます。しかし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(から成功したリターンを得るならば、インデックスが更新されていることを前提としていたが、多分インデックスは、背後に落ちたということです。

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top