Class ParseDateFieldUpdateProcessorFactory
- All Implemented Interfaces:
NamedListInitializedPlugin,SolrCoreAware
Date when they
are mutated.
The default selection behavior is to mutate both those fields that don't match a schema field, as well as those fields that match a schema field with a date field type.
If all values are parseable as dates (or are already Date), then the field will be mutated, replacing each value with its parsed Date equivalent; otherwise, no mutation will occur.
One or more date "format" specifiers must be specified. See Java 8's DateTimeFormatter javadocs for a description of format strings. Note that "lenient" and case insensitivity is enabled. Furthermore, inputs surrounded in single quotes will be removed if found.
A default time zone name or offset may optionally be specified for those dates that don't include an explicit zone/offset. NOTE: three-letter zone designations like "EST" are not parseable (with the single exception of "UTC"), because they are ambiguous. If no default time zone is specified, UTC will be used. See Wikipedia's list of TZ database time zone names.
The locale to use when parsing field values using the specified formats may optionally be
specified. If no locale is configured, then en_US will be used since it's implied by some
well-known formats. Recent versions of Java have become sensitive to this. The following
configuration specifies the French/France locale and two date formats that will parse the strings
"le mardi 8 janvier 2013" and "le 28 déc. 2010 à 15 h 30", respectively. Note that either
individual <str> elements or <arr>-s of <str> elements may be used to specify
the date format(s):
<processor class="solr.ParseDateFieldUpdateProcessorFactory">
<str name="defaultTimeZone">Europe/Paris</str>
<str name="locale">fr_FR</str>
<arr name="format">
<str>'le' EEEE dd MMMM yyyy</str>
<str>'le' dd MMM. yyyy 'à' HH 'h' mm</str>
</arr>
</processor>
See Locale for a description of acceptable language, country (optional) and variant
(optional) values, joined with underscore(s).
Tip: you can use multiple instances of this URP in your chain with different locales or default time zones if you wish to vary those settings for different format patterns.
- Since:
- 4.4.0
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.solr.update.processor.FieldMutatingUpdateProcessorFactory
FieldMutatingUpdateProcessorFactory.SelectorParamsNested classes/interfaces inherited from class org.apache.solr.update.processor.UpdateRequestProcessorFactory
UpdateRequestProcessorFactory.RunAlways -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetDefaultSelector(SolrCore core) Returns true if the field doesn't match any schema field or dynamic field, or if the matched field's type is BoolFieldgetInstance(SolrQueryRequest req, SolrQueryResponse rsp, UpdateRequestProcessor next) voidinit(org.apache.solr.common.util.NamedList<?> args) Handles common initialization related to source fields for constructing the FieldNameSelector to be used.static ObjectparsePossibleDate(Object srcVal, Collection<DateTimeFormatter> parsers, ParsePosition parsePosition) static voidvalidateFormatter(DateTimeFormatter formatter) Methods inherited from class org.apache.solr.update.processor.FieldMutatingUpdateProcessorFactory
getSelector, inform, parseSelectorExclusionParams, parseSelectorParams
-
Constructor Details
-
ParseDateFieldUpdateProcessorFactory
public ParseDateFieldUpdateProcessorFactory()
-
-
Method Details
-
getInstance
public UpdateRequestProcessor getInstance(SolrQueryRequest req, SolrQueryResponse rsp, UpdateRequestProcessor next) - Specified by:
getInstancein classUpdateRequestProcessorFactory
-
init
public void init(org.apache.solr.common.util.NamedList<?> args) Description copied from class:FieldMutatingUpdateProcessorFactoryHandles common initialization related to source fields for constructing the FieldNameSelector to be used.Will error if any unexpected init args are found, so subclasses should remove any subclass-specific init args before calling this method.
- Specified by:
initin interfaceNamedListInitializedPlugin- Overrides:
initin classFieldMutatingUpdateProcessorFactory- Parameters:
args- non-null list of initialization parameters (may be empty)
-
getDefaultSelector
Returns true if the field doesn't match any schema field or dynamic field, or if the matched field's type is BoolField- Overrides:
getDefaultSelectorin classFieldMutatingUpdateProcessorFactory- See Also:
-
parsePossibleDate
public static Object parsePossibleDate(Object srcVal, Collection<DateTimeFormatter> parsers, ParsePosition parsePosition) -
validateFormatter
-