cancel
Showing results for 
Search instead for 
Did you mean: 

Solr random ordering list

haythem_jaiech
Explorer

Hey everyone,

I was traying to override the solr behavior to return each time a random ordering list of products, but I have a big trouble on that and I didn't find an idea to do it.

I found here a documentation, but I don't know how to do it in hybris.

Could someone tell me how could I manage that?

Thanks Haythem,

Accepted Solutions (1)

Accepted Solutions (1)

ArthurPerry
Employee
Employee

I'm curious what use case this would fulfill, other than for testing purposes. The out of the box config/solr/embedded/conf/schema.xml has the random fieldType defined. You just need to define a dynamicField to use that type (i.e. random_*)

Then all you need to do when you query is call query.addOrderField("random_1234") on your SearchQuery. Repeated queries with order random_1234 will provide the products in the same random order. A query with order random_5678 will give a different random ordering. That's per the documentation you referenced ;).

Answers (2)

Answers (2)

haythem_jaiech
Explorer
0 Kudos

Thanks it works for me

haythem_jaiech
Explorer
0 Kudos

Thanks Arthur for your replay I'll implement this and get back to if I found a problem. One of our clients, need to get a random list of product for each call that's why we need to do that.

Regards,