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:

      <fieldType name="random" class="solr.RandomSortField" />
      <dynamicField name="random*" type="random" indexed="true" stored="false"/>
    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.
    solr 1.3