org.apache.solr.schema
Class RandomSortField

java.lang.Object
  extended by org.apache.solr.schema.FieldType
      extended by org.apache.solr.schema.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="rand" indexed="true" stored="false"/>
  ...
 </fields>
 
Examples of queries: Note that multiple calls to the same URL will return the same sorting order.

Since:
solr 1.3
Version:
$Id: RandomSortField.java 819234 2009-09-26 23:46:44Z markrmiller $

Nested Class Summary
 class RandomSortField.RandomValueSource
           
 
Nested classes/interfaces inherited from class org.apache.solr.schema.FieldType
FieldType.DefaultAnalyzer
 
Field Summary
 
Fields inherited from class org.apache.solr.schema.FieldType
analyzer, args, falseProperties, log, queryAnalyzer, trueProperties, typeName
 
Constructor Summary
RandomSortField()
           
 
Method Summary
 SortField getSortField(SchemaField field, boolean reverse)
          Returns the SortField instance that should be used to sort fields of this type.
 ValueSource getValueSource(SchemaField field)
           
 void write(TextResponseWriter writer, String name, Fieldable f)
          calls back to TextResponseWriter to write the field value
 void write(XMLWriter xmlWriter, String name, Fieldable f)
          Renders the specified field as XML
 
Methods inherited from class org.apache.solr.schema.FieldType
createField, getAnalyzer, getArg, getFieldIndex, getFieldStore, getFieldTermVec, getQueryAnalyzer, getRangeQuery, getStringSort, getTypeName, getValueSource, indexedToReadable, init, isMultiValued, isTokenized, multiValuedFieldCache, readableToIndexed, restrictProps, setAnalyzer, setQueryAnalyzer, storedToIndexed, storedToReadable, toExternal, toInternal, toObject, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

RandomSortField

public RandomSortField()
Method Detail

getSortField

public SortField getSortField(SchemaField field,
                              boolean reverse)
Description copied from class: FieldType
Returns the SortField instance that should be used to sort fields of this type.

Specified by:
getSortField in class FieldType

getValueSource

public ValueSource getValueSource(SchemaField field)
Overrides:
getValueSource in class FieldType

write

public void write(XMLWriter xmlWriter,
                  String name,
                  Fieldable f)
           throws IOException
Description copied from class: FieldType
Renders the specified field as XML

Specified by:
write in class FieldType
Throws:
IOException

write

public void write(TextResponseWriter writer,
                  String name,
                  Fieldable f)
           throws IOException
Description copied from class: FieldType
calls back to TextResponseWriter to write the field value

Specified by:
write in class FieldType
Throws:
IOException


Copyright © 2010 Apache Software Foundation. All Rights Reserved.