I followed
and https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-date-format.html but I could not find the answer that required .
I created index using
GET film/_mapping
Also as per the accepted answer in Elasticsearch: Datatype for time(HH:mm:ss.SSS) field
I created my mapping as per below .
PUT film/_mapping
{
"properties": {
"filmname": {
"type": "keyword"
},
"runtime": {
"type": "date",
"format": "hour_minute_second_fraction"
},
"genre": {
"type": "text"
},
"releasedate":{
"type": "date",
"format": "yyyy-MM-dd"
},
"budget":{
"type": "double"
}
}
}
I tried to add a document using below request .
PUT film/_doc/1/
{
"film": "The Terminator",
"runtime": "12_50_30_40",
"genre": "SCIFI war Action",
"releasedate": "1984-11-30",
"budget" : "45.12"
}
But it throws the attached error , actually I want to add this field only in hour_minute_second format.
The format expected by
hour_minute_second_fraction
isHH:mm:ss.SSS
, so in your case, it would mean12:50:30.400
If you want to keep using
12_50_30_40
, then you need to set your own format, like this: