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달 전50회 조회
답변 없음

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠