Randomize results with the same score

I have indexed documents with lot of not analyzed mostly numeric fields and one analyzed field 'title'. And on that data I built search engine which generates less or more complicated bool queries. In results I need to have full diversity of data so simply I need to use random order if data satisfy query. I achieved it using "function score" with "random_score" and everything seems to be ok at least if query gives me true/false answer. But if I use in query analyzed column (title) full randomization of results is not what I want to achieve. I want to preserve an order based on the orginal score. But if, and only if there are results with the same score I need random order inside groups with the same score.

How to achieve that?

This can be achieved by using multi sort on your search request. You want your first sort to be on _score, and your second to be a scripted sort which returns a random value.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.