Skip to content

Commit

Permalink
Document the origin of the DateProcessor format literals (#99388)
Browse files Browse the repository at this point in the history
  • Loading branch information
joegallo committed Sep 11, 2023
1 parent b53756a commit 79bae69
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,10 @@ Function<String, ZonedDateTime> getFunction(String format, ZoneId zoneId, Locale
abstract Function<String, ZonedDateTime> getFunction(String format, ZoneId timezone, Locale locale);

static DateFormat fromString(String format) {
// note: the ALL_CAPS format names here (UNIX_MS, etc) are present for historical reasons:
// they are the format literals that are supported by the logstash date filter plugin
// (see https://www.elastic.co/guide/en/logstash/current/plugins-filters-date.html#plugins-filters-date-match).
// don't extend this list with new special keywords (unless logstash has grown the same keyword).
return switch (format) {
case "ISO8601" -> Iso8601;
case "UNIX" -> Unix;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,13 @@ teardown:
"target_field" : "date_target_7",
"formats" : [ "ISO8601" ]
}
},
{
"date" : {
"field" : "date_source_8",
"target_field" : "date_target_8",
"formats" : [ "epoch_second" ]
}
}
]
}
Expand All @@ -162,7 +169,16 @@ teardown:
index: test
id: "1"
pipeline: "my_pipeline"
body: { date_source_1: "2018-02-05T13:44:56.657+0100", date_source_2: "2017-04-04 13:43:09 +0200", date_source_3: "10/Aug/2018:09:45:56 +0200", date_source_4: "1", date_source_5: "1", date_source_6: "4000000050d506482dbdf024", date_source_7: "2018-02-05T13:44:56.657+0100" }
body: {
date_source_1: "2018-02-05T13:44:56.657+0100",
date_source_2: "2017-04-04 13:43:09 +0200",
date_source_3: "10/Aug/2018:09:45:56 +0200",
date_source_4: "1",
date_source_5: "1",
date_source_6: "4000000050d506482dbdf024",
date_source_7: "2018-02-05T13:44:56.657+0100",
date_source_8: "1688548995.987654321"
}

- do:
get:
Expand All @@ -182,6 +198,7 @@ teardown:
- match: { _source.date_target_6: "2012-12-22T01:00:46.767Z" }
- match: { _source.date_source_7: "2018-02-05T13:44:56.657+0100" }
- match: { _source.date_target_7: "2018-02-05T12:44:56.657Z" }
- match: { _source.date_target_8: "2023-07-05T09:23:15.987Z" }


---
Expand Down

0 comments on commit 79bae69

Please sign in to comment.