public class RandomSortField extends FieldType
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:
| Modifier and Type | Class and Description |
|---|---|
class |
RandomSortField.RandomValueSource |
FieldType.DefaultAnalyzer| Modifier and Type | Field and Description |
|---|---|
private static org.apache.lucene.search.FieldComparatorSource |
randomComparatorSource |
analyzer, args, falseProperties, log, POLY_FIELD_SEPARATOR, properties, queryAnalyzer, trueProperties, typeNameBINARY, INDEXED, MULTIVALUED, OMIT_NORMS, OMIT_POSITIONS, OMIT_TF_POSITIONS, propertyMap, propertyNames, REQUIRED, SORT_MISSING_FIRST, SORT_MISSING_LAST, STORE_TERMOFFSETS, STORE_TERMPOSITIONS, STORE_TERMVECTORS, STORED, TOKENIZED| Constructor and Description |
|---|
RandomSortField() |
| Modifier and Type | Method and Description |
|---|---|
private static int |
getSeed(java.lang.String fieldName,
org.apache.lucene.index.IndexReader r)
Given a field name and an IndexReader, get a random hash seed.
|
org.apache.lucene.search.SortField |
getSortField(SchemaField field,
boolean reverse)
Returns the SortField instance that should be used to sort fields
of this type.
|
ValueSource |
getValueSource(SchemaField field,
QParser parser)
called to get the default value source (normally, from the
Lucene FieldCache.)
|
private static int |
hash(int key) |
void |
write(TextResponseWriter writer,
java.lang.String name,
org.apache.lucene.document.Fieldable f)
calls back to TextResponseWriter to write the field value
|
void |
write(XMLWriter xmlWriter,
java.lang.String name,
org.apache.lucene.document.Fieldable f)
Renders the specified field as XML
|
createField, createField, createFields, getAnalyzer, getArg, getFieldIndex, getFieldQuery, getFieldStore, getFieldTermVec, getIndexOptions, getQueryAnalyzer, getRangeQuery, getStringSort, getTypeName, getValueSource, hasProperty, indexedToReadable, init, isMultiValued, isPolyField, isTokenized, multiValuedFieldCache, readableToIndexed, restrictProps, setAnalyzer, setArgs, setQueryAnalyzer, setTypeName, storedToIndexed, storedToReadable, toExternal, toInternal, toObject, toStringgetPropertyName, off, on, parseProperties, propertiesToString, propertyNameToIntprivate static org.apache.lucene.search.FieldComparatorSource randomComparatorSource
private static int hash(int key)
private static int getSeed(java.lang.String fieldName,
org.apache.lucene.index.IndexReader r)
public org.apache.lucene.search.SortField getSortField(SchemaField field, boolean reverse)
FieldTypegetSortField in class FieldTypeSchemaField.checkSortability()public ValueSource getValueSource(SchemaField field, QParser parser)
FieldTypegetValueSource in class FieldTypepublic void write(XMLWriter xmlWriter, java.lang.String name, org.apache.lucene.document.Fieldable f) throws java.io.IOException
FieldTypepublic void write(TextResponseWriter writer, java.lang.String name, org.apache.lucene.document.Fieldable f) throws java.io.IOException
FieldType