diff --git a/qa/rolling-upgrade/src/test/java/org/elasticsearch/upgrades/IndexingIT.java b/qa/rolling-upgrade/src/test/java/org/elasticsearch/upgrades/IndexingIT.java index b4b519ce82f30..0be7df8d7eb05 100644 --- a/qa/rolling-upgrade/src/test/java/org/elasticsearch/upgrades/IndexingIT.java +++ b/qa/rolling-upgrade/src/test/java/org/elasticsearch/upgrades/IndexingIT.java @@ -219,7 +219,7 @@ public void testDateNanosFormatUpgrade() throws IOException { Request index = new Request("POST", "/" + indexName + "/_doc/"); XContentBuilder doc = XContentBuilder.builder(XContentType.JSON.xContent()) .startObject() - .field("date", "2015-01-01T12:10:30.123456789Z") + .field("date", "2015-01-01T12:10:30.123Z") .field("date_nanos", "2015-01-01T12:10:30.123456789Z") .endObject(); index.addParameter("refresh", "true"); diff --git a/qa/smoke-test-ingest-with-all-dependencies/src/test/resources/rest-api-spec/test/ingest/60_pipeline_timestamp_date_mapping.yml b/qa/smoke-test-ingest-with-all-dependencies/src/test/resources/rest-api-spec/test/ingest/60_pipeline_timestamp_date_mapping.yml index 0f514f2213492..a096814689a64 100644 --- a/qa/smoke-test-ingest-with-all-dependencies/src/test/resources/rest-api-spec/test/ingest/60_pipeline_timestamp_date_mapping.yml +++ b/qa/smoke-test-ingest-with-all-dependencies/src/test/resources/rest-api-spec/test/ingest/60_pipeline_timestamp_date_mapping.yml @@ -9,7 +9,7 @@ index: timetest body: mappings: - "properties": { "my_time": {"type": "date", "format": "strict_date_optional_time_nanos"}} + "properties": { "my_time": {"type": "date_nanos", "format": "strict_date_optional_time_nanos"}} - do: ingest.put_pipeline: diff --git a/rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/search.aggregation/49_range_timezone_bug.yml b/rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/search.aggregation/49_range_timezone_bug.yml index 5785015d7eeb6..bb9b910978844 100644 --- a/rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/search.aggregation/49_range_timezone_bug.yml +++ b/rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/search.aggregation/49_range_timezone_bug.yml @@ -8,7 +8,7 @@ setup: mappings: properties: mydate: - type: date + type: date_nanos format: "uuuu-MM-dd'T'HH:mm:ss.SSSSSSSSSZZZZZ" - do: diff --git a/server/src/main/java/org/elasticsearch/index/mapper/DateFieldMapper.java b/server/src/main/java/org/elasticsearch/index/mapper/DateFieldMapper.java index 687eee3af0ee3..890afe4c02f0c 100644 --- a/server/src/main/java/org/elasticsearch/index/mapper/DateFieldMapper.java +++ b/server/src/main/java/org/elasticsearch/index/mapper/DateFieldMapper.java @@ -75,6 +75,7 @@ public final class DateFieldMapper extends FieldMapper { 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 final String indexName; public enum Resolution { MILLISECONDS(CONTENT_TYPE, NumericType.DATE) { @@ -234,6 +235,7 @@ public static class Builder extends FieldMapper.Builder { private final Parameter nullValue = Parameter.stringParam("null_value", false, m -> toType(m).nullValueAsString, null).acceptsNull(); private final Parameter ignoreMalformed; + private String indexName; private final Parameter