-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Closed
Labels
:Core/Infra/CoreCore issues without another labelCore issues without another label>bugTeam:Core/InfraMeta label for core/infra teamMeta label for core/infra teamhigh hanging fruit
Description
Elasticsearch version: 7.6+
Description of the problem including expected versus actual behavior:
I am not entirely sure what exactly the problem is, but there is some parsing logic with rounding dates up that causes parsing exceptions that do not look like they should be parsing exceptions.
I've written a unit test in JavaDateMathParserTests.java that reproduces the believed issue:
public void testInvalidAMPM() {
DateFormatter formatter = DateFormatter.forPattern("MM/dd/yyyy hh:mm a");
DateMathParser parser = formatter.toDateMathParser();
String date = "04/30/2020 05:48 PM";
parser.parse(date, () -> 0, false, ZoneId.systemDefault());
ElasticsearchParseException exception = expectThrows(ElasticsearchParseException.class,
() -> parser.parse(date, () -> 0, true, ZoneId.systemDefault()));
}
when roundUpProperty is set to true, parsing fails.
Steps to reproduce:
PUT my_index
{
"mappings": {
"properties": {
"date": {
"type": "date",
"ignore_malformed" : false,
"format" : "MM/dd/yyyy hh:mm a z"
}
}
}
}
PUT my_index/_doc/1
{
"date": "04/02/2020 07:48 AM CST"
}
GET my_index/_search
{
"query": {
"range": {
"date": {
"gte": "04/01/2020 07:48 AM CST",
"lte": "04/20/2020 05:48 PM CST"
}
}
}
}
Metadata
Metadata
Assignees
Labels
:Core/Infra/CoreCore issues without another labelCore issues without another label>bugTeam:Core/InfraMeta label for core/infra teamMeta label for core/infra teamhigh hanging fruit