With DocumentDB how do you limit the output of an aggregate pipeline?

0

I have an aggregate pipeline which is pretty much:

[ 
  { "$match" : <filter out some basic stuff>},
  {"$redact" : <more complicated filter>},
  {"$limit":x}
]

Assume that I have 10 documents, and I expect the 2nd, 5th, and 8th to be returned

If I set x to 10 then I will get all 3

if I set x to 8 then I will still get 3

if I set x to 7 then I only get the 2nd and 5th

if I set x to 4 then I only get the 2nd

If I set x to 1 then I don't get any results

So based on my experiments it looks like the limit is applied to the input, not the output. The same aggregate run against mongoDb behaves as I would expect (x == 3 returns 2nd,5th,8th x == 2 return 2nd,5th x==1 returns 2nd)

How do I get it to behave the same as mongoDb where the limit will apply after the redact stage rather than before it.

Ian
質問済み 7ヶ月前49ビュー
回答なし

ログインしていません。 ログイン 回答を投稿する。

優れた回答とは、質問に明確に答え、建設的なフィードバックを提供し、質問者の専門分野におけるスキルの向上を促すものです。

質問に答えるためのガイドライン

関連するコンテンツ