Class RandomSortField


  • public class RandomSortField
    extends FieldType
    Utility Field used for random sorting. It should not be passed a value.

    This random sorting implementation uses the dynamic field name to set the random 'seed'. To get random sorting order, you need to use a random dynamic field name. For example, you will need to configure schema.xml:

     <types>
      ...
      <fieldType name="random" class="solr.RandomSortField" />
      ...
     </types>
     <fields>
      ...
      <dynamicField name="random*" type="random" indexed="true" stored="false"/>
      ...
     </fields>
     
    Examples of queries:
    • http://localhost:8983/solr/select/?q=*:*&fl=name&sort=random_1234%20desc
    • http://localhost:8983/solr/select/?q=*:*&fl=name&sort=random_2345%20desc
    • http://localhost:8983/solr/select/?q=*:*&fl=name&sort=random_ABDC%20desc
    • http://localhost:8983/solr/select/?q=*:*&fl=name&sort=random_21%20desc
    Note that multiple calls to the same URL will return the same sorting order.
    Since:
    solr 1.3