I have a similar goal to this question, which is closed.
example document:
{
…
sponsor: true
…
}
Other fields of the document doesnt matter. I’m currently doing a complex aggregation pipeline with match, sort, facet, project and other stages. What I would like to do is pick only 1 random document from the results that has sponsored field, place it on top of the results, and leave the rest of the results intact without altering the query and sort.
I can’t do this after the aggregation because I’m paginating, and one of the sponsored documents might be on the other pages. Even if it’s one the third page, I want it to be on the first result. Is this possible?
However, as OP said, this results in inaccurate pagination. I can just change the numbers in the pages and let them be 1-11, 1-9 etc, but if there is a way to make this organically, please let me know.