Date formatting for import

I have a date field that is in the following format:
01-JAN-20

When I map the field to dd-MMM-yy it won't accept the date above but it will accept the following:
01-Jan-20

Is there a way to get Elasticsearch to accept the former?

PUT tctestindex
{
  "mappings": {
    "properties": {
      "date": {
        "type": "date", 
        "format": "d-MMM-yy"
      }
    }
  }
}

# works!
PUT tctestindex/_doc/1
{ "date": "01-Jan-20" }

#fails!
PUT tctestindex/_doc/2
{ "date": "01-JAN-20" }

Hey,

I do not think is possible, after a quick scan of https://docs.oracle.com/javase/8/docs/api/java/time/format/DateTimeFormatter.html (you may want to take a look yourself).

You could maybe convert this using a script processor and some text wranling.

--Alex

@spinscale - thanks for the response. I did see that link and saw this line:
M/L month-of-year number/text 7; 07; Jul; July; J

I just thought I might be missing something; specifically with what the "L" is for.

the L is for the name only, but still requires the first (and only the first) letter to be uppercased from what I understand.

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