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 https://github.com/x2find/Random2Find 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
I have used it, and it works very well with EPiServer Find. I have tested it with latest Find version (10.0.0.3291).
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,
Are there other ideas on the organization random sort order with pagination?
It doesn't really make sense to use pagination if you have random sort order, does it?
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
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.
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.
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).
Thanks Henrik Fransas for correcting my mistake