|
@@ -64,6 +64,8 @@ public final class DateFieldMapper extends FieldMapper {
|
|
|
public static final String CONTENT_TYPE = "date";
|
|
|
public static final String DATE_NANOS_CONTENT_TYPE = "date_nanos";
|
|
|
public static final DateFormatter DEFAULT_DATE_TIME_FORMATTER = DateFormatter.forPattern("strict_date_optional_time||epoch_millis");
|
|
|
+ public static final DateFormatter DEFAULT_DATE_TIME_NANOS_FORMATTER =
|
|
|
+ DateFormatter.forPattern("strict_date_optional_time_nanos||epoch_millis");
|
|
|
private static final DateMathParser EPOCH_MILLIS_PARSER = DateFormatter.forPattern("epoch_millis").toDateMathParser();
|
|
|
|
|
|
public enum Resolution {
|
|
@@ -216,8 +218,7 @@ public final class DateFieldMapper extends FieldMapper {
|
|
|
|
|
|
private final Parameter<Map<String, String>> meta = Parameter.metaParam();
|
|
|
|
|
|
- private final Parameter<String> format
|
|
|
- = Parameter.stringParam("format", false, m -> toType(m).format, DEFAULT_DATE_TIME_FORMATTER.pattern());
|
|
|
+ private final Parameter<String> format;
|
|
|
private final Parameter<Locale> locale = new Parameter<>("locale", false, () -> Locale.ROOT,
|
|
|
(n, c, o) -> LocaleUtils.parse(o.toString()), m -> toType(m).locale);
|
|
|
|
|
@@ -235,6 +236,10 @@ public final class DateFieldMapper extends FieldMapper {
|
|
|
this.indexCreatedVersion = indexCreatedVersion;
|
|
|
this.ignoreMalformed
|
|
|
= Parameter.boolParam("ignore_malformed", true, m -> toType(m).ignoreMalformed, ignoreMalformedByDefault);
|
|
|
+
|
|
|
+ DateFormatter defaultFormat = resolution == Resolution.MILLISECONDS ?
|
|
|
+ DEFAULT_DATE_TIME_FORMATTER : DEFAULT_DATE_TIME_NANOS_FORMATTER;
|
|
|
+ this.format = Parameter.stringParam("format", false, m -> toType(m).format, defaultFormat.pattern());
|
|
|
if (dateFormatter != null) {
|
|
|
this.format.setValue(dateFormatter.pattern());
|
|
|
this.locale.setValue(dateFormatter.locale());
|