Is there a way in which documents coming from a search can be sorted in a linear fashion using some logic that requires keeping a state. I want to push the documents matching a particular tag that is already seen to the end of the search. This requires a list that contains the list of tags already seen to decide whether to put the product in place or move it to the end. The use case here is that documents has to be sorted and filtered as per requirement, but in the end there should be way to move the duplicate tag documents to the end of the list.
In this case, given two documents in the index, you can't determine which would come before the other. To decide that we need to know what products are already sorted, whose places have been finalized as before the current two.