I have an issue that I am not quite sure how to solve. Really hope someone here can help me figure out how to go about it.
Imagine that I have 100 documents, all with user_id fields. I know that most documents are from different user_ids, but documents 1-10 and 20-29 are from the same user_id.
What I want to do, is make sure that I only see the the latest two documents whenever a the same user_id is returned in a row more than twice. So if user_id 1 shows up more than twice in a row, I want to limit those documents. I want this to happen every time it happens for that user_id, not limit it completely after that.
If I just request all documents as they are indexed now, I would get a result like:
[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, ...]
What I am loooking for, us a way to make sure these groups of 1s, are limited to two documents in a row, like so:
[1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 1, 1, 12, ...]
Notice that 1, 1, ..., 1, 1, ...
happens here, meaning that the rows of identical user ids have been cut down to two, instead of removing them all together, which would result in something like:
[1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, ...]
I also want this to work if the request is paginated (Multiple queries).
So imagine that I request the first two pages, with a size of 5, then I would like to get:
Page1: [1, 1, 2, 3, 4]
Page2: [5, 6, 7, 8, 9]
Instead of:
Page1: [1, 1, 2, 3, 4]
Page2: [1, 1, 1, 1, 1]
I hope that I have described the issue well enough for someone to understand. If not, then please let me know so I can try explaining it another way.