Class SortableTextField
- Direct Known Subclasses:
NestPathField
SortableTextField is a specialized form of TextField that supports Sorting
and ValueSource functions, using docValues built from the first
maxCharsForDocValues characters of the original (pre-analyzed) String values of this
field.
The implicit default value for maxCharsForDocValues is 1024. If a
field type instance is configured with maxCharsForDocValues <= 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 with docValues="false".
Just like StrField, instances of this field that are multiValued="true"
support the field(name,min|max) function, and implicitly sort on min|max
depending on the asc|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 set useDocValuesAsStored="true" then instead of
truncating the original string value based on the effective value of maxCharsForDocValues
, 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 a
stored value.
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.solr.schema.FieldType
FieldType.DefaultAnalyzer, FieldType.MultiValueSelector -
Field Summary
FieldsFields inherited from class org.apache.solr.schema.TextField
autoGeneratePhraseQueries, enableGraphQueries, multiTermAnalyzer, synonymQueryStyleFields 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, typeNameFields 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 -
Method Summary
Modifier and TypeMethodDescriptionprotected voidCalled byFieldType.checkSchemaField(SchemaField)if the field has docValues.List<org.apache.lucene.index.IndexableField> createFields(SchemaField field, Object value) Given aSchemaField, create one or moreIndexableFieldinstancesprotected booleanReturns whether this field type should enable docValues by default for schemaVersion >= 1.7.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.ValueSourcegetSingleValueSource(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.SortFieldgetSortField(SchemaField field, boolean reverse) Returns the SortField instance that should be used to sort fields of this type.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.ValueSourcegetValueSource(SchemaField field, QParser parser) called to get the default value source (normally, from the Lucene FieldCache.)protected voidinit(IndexSchema schema, Map<String, String> args) subclasses should initialize themselves with the args provided and remove valid arguments.booleanReturns 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, writeMethods 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 Details
-
DEFAULT_MAX_CHARS_FOR_DOC_VALUES
public static final int DEFAULT_MAX_CHARS_FOR_DOC_VALUES- See Also:
-
-
Constructor Details
-
SortableTextField
public SortableTextField()
-
-
Method Details
-
init
Description copied from class:FieldTypesubclasses 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
Description copied from class:FieldTypeGiven aSchemaField, create one or moreIndexableFieldinstances- Overrides:
createFieldsin classFieldType- Parameters:
field- theSchemaFieldvalue- The value to add to the field- Returns:
- An array of
IndexableField - See Also:
-
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:
checkSupportsDocValuesin classFieldType
-
enableDocValuesByDefault
protected boolean enableDocValuesByDefault()Description copied from class:FieldTypeReturns whether this field type should enable docValues by default for schemaVersion >= 1.7. This should not be enabled for fields that did not have docValues implemented by Solr 9.7, as users may have indexed documents without docValues (since they weren't supported). Flipping the default docValues values when they upgrade to a new version will break their index compatibility.New field types can enable this without issue, as long as they support docValues.
- Overrides:
enableDocValuesByDefaultin classFieldType
-
getSortField
Description copied from class:FieldTypeReturns the SortField instance that should be used to sort fields of this type.- Overrides:
getSortFieldin classTextField- See Also:
-
getValueSource
public org.apache.lucene.queries.function.ValueSource getValueSource(SchemaField field, QParser parser) Description copied from class:FieldTypecalled to get the default value source (normally, from the Lucene FieldCache.)- Overrides:
getValueSourcein classTextField
-
getDefaultMultiValueSelectorForSort
public FieldType.MultiValueSelector getDefaultMultiValueSelectorForSort(SchemaField field, boolean reverse) Description copied from class:FieldTypeMethod 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:
getDefaultMultiValueSelectorForSortin 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:
-
getSingleValueSource
public org.apache.lucene.queries.function.ValueSource getSingleValueSource(FieldType.MultiValueSelector choice, SchemaField field, QParser parser) Description copied from class:FieldTypeMethod 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
SchemaFieldthat is in fact not-multivalued, in which case it delegates toFieldType.getValueSource(org.apache.solr.schema.SchemaField, org.apache.solr.search.QParser)- Overrides:
getSingleValueSourcein classFieldType- See Also:
-
getUninversionType
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 uninvertible, this method always returns null- Overrides:
getUninversionTypein classTextField- Parameters:
sf- field instance- Returns:
- type to uninvert, or
null(to disallow uninversion for the field) - See Also:
-
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:
multiValuedFieldCachein classFieldType
-