How to return slightly randomized results?

When entering a search term and getting back the results sorted by score, is there a way to get it to return slightly randomized results?

I don't mean totally random. I mean maybe a small random multiplier could be added to all the scores on the server side so that it still displays more relevant results first, but in a slightly different order.

I'd like to do this randomization on the server side, so that it's randomized before sending to the client. Otherwise if do it on the client side, if I request the first 20 hits it'll always be the same 20 just in a different order.

I'm not sure if I've explained it clearly, please let me know.

You can use Random Score for now: See https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-function-score-query.html

Thank you!

How could I customize how much "randomness" to apply? I'd like elasticsearch to apply either a very slight or a very large randomization to what each document's original score would have been (e.g. multiplying it by a tiny or a large factor). That way I could configure whether I want to multiply it by a tiny factor or a large one depending on how much customization I'd like.

But random_score has only seed and field options so I can't see how to do this. How could I do it?

I believe that "boost_mode" helps you to define this, no?

But may be I did not understand.

Worse case you can run a Script: https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-function-score-query.html#function-script-score

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