We have an ecommerce products index, which has Brand field(keyword) and a PublishDate field(date).
We need a New items sort, which should sort results by returning
no more than 5 consecutive products of each brand sorted by PublishDate , the index is size 10k+ and needs pagination.
BrandA - 7 products(5 with same PublishDate and 2 with the older PublishDate)
BrandB - 6 products(5 with same PublishDate, older than BrandA first 5 and 1 older then the others))
BrandC - 3 products(PublishDate is older then BrandA and BrandB)
We should have results [BrandA, BrandA, BrandA, BrandA, BrandA, BrandB, BrandB, BrandB, BrandB, BrandB, BrandC, BrandC, BrandC, BrandA, BrandA, Brand B]