Date field format issue

I have the following query that I'm trying to run on Elasticsearch 5.6 in Kibana Dev Tools:

    {
  "query": {
    "bool": {
      "filter": {
        "bool": {
          "must": [
            {
              "range": {
                "inserted": {
                  "gt": "Thu Aug 20 09:01:31 +0100 2020"
                }
              }
            }
          ]
        }
      }
    }
  }
}

the response I'm getting is:

{
  "error": {
    "root_cause": [
      {
        "type": "parse_exception",
        "reason": "failed to parse date field [Thu Aug 20 09:01:31 +0100 2020] with format [EEE MMM dd HH:mm:ss ZZZ yyyy]"
      }
    ],
    "type": "search_phase_execution_exception",
    "reason": "all shards failed",
    "phase": "can_match",
    "grouped": true,

The datetime format looks correct to me, what am I doing wrong?

If you look at the docs for the date type the default format, if you have not specified something else in your mappings, is strict_date_optional_time, e.g. 2015-01-01T12:10:30Z. The format you used is not standard.

Yes I know the field is not on the default format, but I do need to query for that format.
The format I'm using seems to be the one it wants, why can it not parse?

thanks

Have you specified that format in your mappings for that field? If not I believe you need to do so.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.