Try our conversational search powered by Generative AI!

Random sort order


Hi guys,

We need to implement random sort order for our application. It should support pagination.

How can we add random sort order to the request?

P.S. I found some solution but it haven't updated. It also throw exseption.

What do you think about this implementation?

Will it works properly with EPiServer Find (now, in the feature)?

Is it good enough according application performance?

I hope for your help

Nov 13, 2015 10:23

I have used it, and it works very well with EPiServer Find.  I have tested it with latest Find version (

Nov 16, 2015 12:29

I have cheked this plugin but it seems we can't use pagination.

I've tried to improve script but EPiServer Find forbids custom scripts.

Solution available in the elastic:

        public static ITypeSearch<T> OrderRandomSalt<T>(this ITypeSearch<T> search, string salt)
            return new Search<T, IQuery>(search, context =>
                var sortScript = new ScriptSorting
                    Script = "org.elasticsearch.common.Digest.md5Hex(doc['_id'].value + salt)",
                    Language = ScriptLanguage.Native,
                    Type = ScriptSortType.String,
                sortScript.AddParameter("salt", salt);

Are there other ideas on the organization random sort order with pagination?

Edited, Nov 18, 2015 12:24

It doesn't really make sense to use pagination if you have random sort order, does it? 

Nov 18, 2015 12:26

As Mari says it really does not make sense since the ordering will be different for each request.

If you want pagination the only solution I can think of is to use this but get all content back and do paginations by client side code

Nov 18, 2015 12:37

It make sense when you have a lot of items and can't show (retrieve) all of them. 

Sorting can be based on a key value. If you change key than the order will change. If you use the same key you will get the same result.

EPiServer Find returns search result with random order. As a result, I can't show result by portions without applying alphabetical sort order.

Nov 18, 2015 12:42

Your original post stated "We need to implement random sort order for our application..." and we suggest to use Random2Find.

It is not clear what you are trying to do....

If you need paging, then you should specify a sort order (can be whatever field you like).  If you want random sort order, then it does not make sense to have paging.

Nov 18, 2015 12:52

episerver find does not return results in random order, if you do not specify they will be returned based on relevance and that should be the same for page two as for page one if you have not updated the index in the time it takes for the visitor to klick on page 2 (or if you change any requrements on the search).

Nov 18, 2015 13:01

Thanks Henrik Fransas for correcting my mistake

Nov 18, 2015 14:23
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.