Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,6 @@ private long parseMillis(String date) {

@Override
Function<String, ZonedDateTime> getFunction(String format, ZoneId zoneId, Locale locale) {
// support the 6.x BWC compatible way of parsing java 8 dates
if (format.startsWith("8")) {
format = format.substring(1);
}

boolean isUtc = ZoneOffset.UTC.equals(zoneId);

DateFormatter dateFormatter = DateFormatter.forPattern(format)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
---
"Test Index and Search locale dependent mappings / dates":
- skip:
version: "all"
reason: "Awaits fix: https://github.com/elastic/elasticsearch/issues/39981(Previously: JDK9 only supports this with a special sysproperty added in 6.2.0.)"
version: " - 6.1.99"
reason: JDK9 only supports this with a special sysproperty added in 6.2.0
- do:
indices.create:
index: test_index
Expand All @@ -13,7 +13,7 @@
properties:
date_field:
type: date
format: "E, d MMM yyyy HH:mm:ss Z"
format: "8E, d MMM uuuu HH:mm:ss Z"
locale: "de"
- do:
bulk:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,27 +129,28 @@ default String formatJoda(DateTime dateTime) {
DateMathParser toDateMathParser();

static DateFormatter forPattern(String input) {

if (Strings.hasLength(input) == false) {
throw new IllegalArgumentException("No date pattern provided");
}

// support the 6.x BWC compatible way of parsing java 8 dates
if (input.startsWith("8")) {
input = input.substring(1);
}

List<String> patterns = splitCombinedPatterns(input);
String format = strip8Prefix(input);
List<String> patterns = splitCombinedPatterns(format);
List<DateFormatter> formatters = patterns.stream()
.map(DateFormatters::forPattern)
.collect(Collectors.toList());

if (formatters.size() == 1) {
return formatters.get(0);
}

return JavaDateFormatter.combined(input, formatters);
}

static String strip8Prefix(String input) {
if (input.startsWith("8")) {
return input.substring(1);
}
return input;
}

static List<String> splitCombinedPatterns(String input) {
List<String> patterns = new ArrayList<>();
for (String pattern : Strings.delimitedListToStringArray(input, "||")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -339,4 +339,21 @@ public DocumentMapper updateFieldType(Map<String, MappedFieldType> fullNameToFie
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
return mapping.toXContent(builder, params);
}

@Override
public String toString() {
return "DocumentMapper{" +
"mapperService=" + mapperService +
", type='" + type + '\'' +
", typeText=" + typeText +
", mappingSource=" + mappingSource +
", mapping=" + mapping +
", documentParser=" + documentParser +
", fieldMappers=" + fieldMappers +
", objectMappers=" + objectMappers +
", hasNestedObjects=" + hasNestedObjects +
", deleteTombstoneMetadataFieldMappers=" + Arrays.toString(deleteTombstoneMetadataFieldMappers) +
", noopTombstoneMetadataFieldMappers=" + Arrays.toString(noopTombstoneMetadataFieldMappers) +
'}';
}
}