0

I filled ElasticSearch with dictionaries. I want to mapp one key to the date in Kibana:

rep_ID:TZ14 createdOn:1,522,158,913,843

The value of the key'creatOn' should be the date. I tried the Painless Scripts in Dev Tools:

PUT testindex
{
  "mappings": {
    "_doc": {
     "properties": {    
            "creatOn": {
          "type": "date" 
        }
      }
    }
  }
}





PUT testindex
{
  "mappings": {
    "_doc": {
      "properties": {
        "creatOn": {
          "type":   "date",
          "format": "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis"
        }
      }
    }
  }
 }

it gives me an error and it doesnt work. I deleted the data. then I ran that scripts and then I filled the data again. And I tried it also in the opposite way. What ist wrong ?

BaseFloor
  • 47
  • 1
  • 2
  • 5

1 Answers1

0

you can try like this

PUT testindex
{
  "mappings": {
    "_doc": {
      "properties": {
        "creatOn": {
          "type":   "date",
          "format": "strict_date_optional_time"
        }
      }
    }
  }
 }

Internally, dates are converted to UTC (if the time-zone is specified) and stored as a long number representing milliseconds-since-the-epoch.

Date formats can be customised, but if no format is specified then it uses the default: "strict_date_optional_time||epoch_millis"

More informations on this page elastic date doc

Elastock
  • 3
  • 2