Class SortableTextField
- java.lang.Object
-
- org.apache.solr.schema.FieldProperties
-
- org.apache.solr.schema.FieldType
-
- org.apache.solr.schema.TextField
-
- org.apache.solr.schema.SortableTextField
-
- Direct Known Subclasses:
NestPathField
public class SortableTextField extends TextField
SortableTextField
is a specialized form ofTextField
that supports Sorting and ValueSource functions, usingdocValues
built from the firstmaxCharsForDocValues
characters of the original (pre-analyzed) String values of this field.The implicit default value for
maxCharsForDocValues
is1024
. If a field type instance is configured withmaxCharsForDocValues <= 0
this overrides the default with an effective value of "no limit" (Integer.MAX_VALUE
).Instances of this FieldType implicitly default to
docValues="true"
unless explicitly configured withdocValues="false"
.Just like
StrField
, instances of this field that aremultiValued="true"
support thefield(name,min|max)
function, and implicitly sort onmin|max
depending on theasc|desc
direction selector.NOTE: Unlike most other FieldTypes, this class defaults to
useDocValuesAsStored="false"
. If an instance of this type (or a field that uses this type) overrides this behavior to setuseDocValuesAsStored="true"
then instead of truncating the original string value based on the effective value ofmaxCharsForDocValues
, this class will reject any documents w/a field value longer then that limit -- causing the document update to fail. This behavior exists to prevent situations that could result in a search client reieving only a truncated version of the original field value in place of astored
value.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.apache.solr.schema.FieldType
FieldType.DefaultAnalyzer, FieldType.MultiValueSelector
-
-
Field Summary
Fields Modifier and Type Field Description static int
DEFAULT_MAX_CHARS_FOR_DOC_VALUES
-
Fields inherited from class org.apache.solr.schema.TextField
autoGeneratePhraseQueries, enableGraphQueries, multiTermAnalyzer, synonymQueryStyle
-
Fields inherited from class org.apache.solr.schema.FieldType
ANALYZER, args, AUTO_GENERATE_PHRASE_QUERIES, CHAR_FILTER, CHAR_FILTERS, CLASS_NAME, docValuesFormat, ENABLE_GRAPH_QUERIES, falseProperties, FILTER, FILTERS, INDEX, INDEX_ANALYZER, MULTI_TERM, MULTI_TERM_ANALYZER, POLY_FIELD_SEPARATOR, postingsFormat, properties, QUERY, QUERY_ANALYZER, similarity, SIMILARITY, similarityFactory, SYNONYM_QUERY_STYLE, TOKENIZER, trueProperties, TYPE, TYPE_NAME, typeName
-
Fields inherited from class org.apache.solr.schema.FieldProperties
BINARY, DOC_VALUES, INDEXED, LARGE_FIELD, MULTIVALUED, OMIT_NORMS, OMIT_POSITIONS, OMIT_TF_POSITIONS, REQUIRED, SORT_MISSING_FIRST, SORT_MISSING_LAST, STORE_OFFSETS, STORE_TERMOFFSETS, STORE_TERMPAYLOADS, STORE_TERMPOSITIONS, STORE_TERMVECTORS, STORED, TOKENIZED, UNINVERTIBLE, USE_DOCVALUES_AS_STORED
-
-
Constructor Summary
Constructors Constructor Description SortableTextField()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
checkSupportsDocValues()
Called byFieldType.checkSchemaField(SchemaField)
if the field has docValues.List<org.apache.lucene.index.IndexableField>
createFields(SchemaField field, Object value)
Given aSchemaField
, create one or moreIndexableField
instancesFieldType.MultiValueSelector
getDefaultMultiValueSelectorForSort(SchemaField field, boolean reverse)
Method for indicating whichFieldType.MultiValueSelector
(if any) should be used when sorting on a multivalued field of this type for the specified direction (asc/desc).org.apache.lucene.queries.function.ValueSource
getSingleValueSource(FieldType.MultiValueSelector choice, SchemaField field, QParser parser)
Method for dynamically building a ValueSource based on a single value of a multivalued field.org.apache.lucene.search.SortField
getSortField(SchemaField field, boolean reverse)
Returns the SortField instance that should be used to sort fields of this type.UninvertingReader.Type
getUninversionType(SchemaField sf)
If DocValues is not enabled for a field, but it's indexed, docvalues can be constructed on the fly (uninverted, aka fieldcache) on the first request to sort, facet, etc.org.apache.lucene.queries.function.ValueSource
getValueSource(SchemaField field, QParser parser)
called to get the default value source (normally, from the Lucene FieldCache.)protected void
init(IndexSchema schema, Map<String,String> args)
subclasses should initialize themselves with the args provided and remove valid arguments.boolean
multiValuedFieldCache()
Returns true if a single field value of this type has multiple logical values for the purposes of faceting, sorting, etc.-
Methods inherited from class org.apache.solr.schema.TextField
analyzeMultiTerm, getAutoGeneratePhraseQueries, getEnableGraphQueries, getFieldQuery, getFieldTermQuery, getMultiTermAnalyzer, getSpecializedRangeQuery, getSynonymQueryStyle, isExplicitMultiTermAnalyzer, isUtf8Field, marshalSortValue, setIsExplicitMultiTermAnalyzer, setMultiTermAnalyzer, supportsAnalyzers, toObject, unmarshalSortValue, write
-
Methods inherited from class org.apache.solr.schema.FieldType
checkSchemaField, createField, createField, getAnalyzerProperties, getClassArg, getDocValuesFormat, getExistenceQuery, getIndexAnalyzer, getNamedPropertyValues, getNonFieldPropertyArgs, getNumberType, getNumericSort, getPostingsFormat, getPrefixQuery, getQueryAnalyzer, getRangeQuery, getRewriteMethod, getSetQuery, getSimilarity, getSimilarityFactory, getSortedNumericSortField, getSortedSetSortField, getSortField, getSpecializedExistenceQuery, getStringSort, getTypeName, hasProperty, indexedToReadable, indexedToReadable, isExplicitAnalyzer, isExplicitQueryAnalyzer, isMultiValued, isPointField, isPolyField, isTokenized, marshalBase64SortValue, marshalStringSortValue, readableToIndexed, readableToIndexed, restrictProps, setArgs, setIndexAnalyzer, setIsExplicitAnalyzer, setIsExplicitQueryAnalyzer, setQueryAnalyzer, setSimilarity, storedToIndexed, storedToReadable, toExternal, toInternal, toNativeType, toObject, toString, treatUnboundedRangeAsExistence, unmarshalBase64SortValue, unmarshalStringSortValue, useDocValuesAsStored, write
-
-
-
-
Field Detail
-
DEFAULT_MAX_CHARS_FOR_DOC_VALUES
public static final int DEFAULT_MAX_CHARS_FOR_DOC_VALUES
- See Also:
- Constant Field Values
-
-
Method Detail
-
init
protected void init(IndexSchema schema, Map<String,String> args)
Description copied from class:FieldType
subclasses should initialize themselves with the args provided and remove valid arguments. leftover arguments will cause an exception. Common boolean properties have already been handled.
-
createFields
public List<org.apache.lucene.index.IndexableField> createFields(SchemaField field, Object value)
Description copied from class:FieldType
Given aSchemaField
, create one or moreIndexableField
instances- Overrides:
createFields
in classFieldType
- Parameters:
field
- theSchemaField
value
- The value to add to the field- Returns:
- An array of
IndexableField
- See Also:
FieldType.createField(SchemaField, Object)
,FieldType.isPolyField()
-
checkSupportsDocValues
protected void checkSupportsDocValues()
Called byFieldType.checkSchemaField(SchemaField)
if the field has docValues. By default none do. this field type supports DocValues, this method is always a No-Op- Overrides:
checkSupportsDocValues
in classFieldType
-
getSortField
public org.apache.lucene.search.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.
-
getValueSource
public org.apache.lucene.queries.function.ValueSource getValueSource(SchemaField field, QParser parser)
Description copied from class:FieldType
called to get the default value source (normally, from the Lucene FieldCache.)- Overrides:
getValueSource
in classTextField
-
getDefaultMultiValueSelectorForSort
public FieldType.MultiValueSelector getDefaultMultiValueSelectorForSort(SchemaField field, boolean reverse)
Description copied from class:FieldType
Method for indicating whichFieldType.MultiValueSelector
(if any) should be used when sorting on a multivalued field of this type for the specified direction (asc/desc). The default implementation returnsnull
(for all inputs).- Overrides:
getDefaultMultiValueSelectorForSort
in classFieldType
- Parameters:
field
- The SchemaField (of this type) in questionreverse
- false if this is an ascending sort, true if this is a descending sort.- Returns:
- the implicit selector to use for this direction, or null if implicit sorting on the specified direction is not supported and should return an error.
- See Also:
FieldType.MultiValueSelector
-
getSingleValueSource
public org.apache.lucene.queries.function.ValueSource getSingleValueSource(FieldType.MultiValueSelector choice, SchemaField field, QParser parser)
Description copied from class:FieldType
Method for dynamically building a ValueSource based on a single value of a multivalued field.The default implementation throws an error except in the trivial case where this method is used on a
SchemaField
that is in fact not-multivalued, in which case it delegates toFieldType.getValueSource(org.apache.solr.schema.SchemaField, org.apache.solr.search.QParser)
- Overrides:
getSingleValueSource
in classFieldType
- See Also:
FieldType.MultiValueSelector
-
getUninversionType
public UninvertingReader.Type getUninversionType(SchemaField sf)
If DocValues is not enabled for a field, but it's indexed, docvalues can be constructed on the fly (uninverted, aka fieldcache) on the first request to sort, facet, etc. This specifies the structure to use.This method will not be used if the field is (effectively)
uninvertible="false"
this field type is not uninvertable, this method always returns null- Overrides:
getUninversionType
in classTextField
- Parameters:
sf
- field instance- Returns:
- type to uninvert, or
null
(to disallow uninversion for the field) - See Also:
SchemaField.isUninvertible()
-
multiValuedFieldCache
public boolean multiValuedFieldCache()
Returns true if a single field value of this type has multiple logical values for the purposes of faceting, sorting, etc. Text fields normally return true since each token/word is a logical value. This implementation always returns false.- Overrides:
multiValuedFieldCache
in classFieldType
-
-