Breaking change v6 to v7 to search date_time_parse_exception 'hh:mm:ss a'

I have tested that the following query works in versions of ES 6 (6.2.3, 6.8.2), but fails in versions of 7 (7.1.1, 7.3.1).

The query is:

{
  "query": {
    "bool": {
      "filter": [
        {
          "range": {
            "runServiceTimeUTC": {
              "gte": "12:50:00 PM",
              "lte": "01:10:00 PM",
              "format": "hh:mm:ss a"
            }
          }
        }
      ]
    }
  }
}

The field is formatted as a date with format 'hh:mm:ss a':

"runServiceTimeUTC" : {
  "type" : "date",
  "format" : "hh:mm:ss a"
}

The resulting error in v7 (7.1.1, 7.3.1) is as follows:

{
  "error": {
    "root_cause": [
      {
        "type": "parse_exception",
        "reason": "failed to parse date field [01:10:00 PM] with format [hh:mm:ss a]: [Text '01:10:00 PM' could not be parsed: Conflict found: HourOfDay 23 differs from HourOfDay 13 while resolving  AmPmOfDay]"
      }
    ],
    "type": "search_phase_execution_exception",
    "reason": "all shards failed",
    "phase": "query",
    "grouped": true,
    "failed_shards": [
      {
        "shard": 0,
        "index": "rundirections_43800dac-9f95-40f2-9414-3dc58ac3234a_1579189356676",
        "node": "jI6lf6EFSimbcIRTzk2MAQ",
        "reason": {
          "type": "parse_exception",
          "reason": "failed to parse date field [01:10:00 PM] with format [hh:mm:ss a]: [Text '01:10:00 PM' could not be parsed: Conflict found: HourOfDay 23 differs from HourOfDay 13 while resolving  AmPmOfDay]",
          "caused_by": {
            "type": "date_time_parse_exception",
            "reason": "Text '01:10:00 PM' could not be parsed: Conflict found: HourOfDay 23 differs from HourOfDay 13 while resolving  AmPmOfDay",
            "caused_by": {
              "type": "date_time_exception",
              "reason": "Conflict found: HourOfDay 23 differs from HourOfDay 13 while resolving  AmPmOfDay"
            }
          }
        }
      }
    ]
  },
  "status": 400
}

If I change the range query to read as follows, the query suddenly works:

{
  "range": {
    "runServiceTimeUTC": {
      "gte": "12:50:00 PM",
      "lte": "13:10:00 PM",
      "format": "HH:mm:ss a"
    }
  }
}

Any ideas what's going wrong here?

Hey,

european time person here (so I may be fully off), but isn't it the case, that PM dates only range up to 12 and there is no such thing like 13:10:00 PM (but rather 01:10:00 PM, this this is not a valid date and parsing fails.

--Alex

Hi Alex,

You're absolutely correct, which is why I am confused as to why the last query (13:10:00 PM) actually works correctly when formatted as 'HH:mm:ss a,' but the first query (01:10:00 PM) does NOT work when formatted as 'hh:mm:ss a.'

The exception reason would indicate that the parser does recognize the hour of day as 13 from the 01 and the PM, but the 'HourOfDay 23' doesn't really make much sense to me...

Have you been able to recreate this issue?

Yes, I think some leniency has been removed here in order to specify invalid dates.

But the following is not an invalid date (as far as I can tell):

"gte": "12:50:00 PM",
"lte": "01:10:00 PM",
"format": "hh:mm:ss a"

And yet, it fails.

yes, as it was working before, please open an issue with two reproducible examples (old and new), so the developers can take a look.