Date mapping in elasticsearch

I have to store date in the index as date format. My mappings are

PUT logstash_testing/logs/_mapping
{
  "properties": {
    "ActualDateTime": {
      "type": "keyword"
    },
    "Priority": {
      "type": "keyword"
    },
    "FailureReason": {
      "type": "keyword"
    },
    "MessageSubmissionTime": {
      "type": "date",
      "format": [ "EEE MMM dd HH:mm:ss.SSS yyyy" ]
    },
    "MessageDeliveryTime": {
      "type": "date",
      "format": [ "EEE MMM dd HH:mm:ss.SSS yyyy" ]
    },
    "RecordType": {
      "type": "keyword"
    }
  }
}

As per the documents I refereed the Joda time and defined my mapping like above

Sample data:

POST logstash_testing/logs/1
{
"ActualDateTime": "test",
"Priority": "Normal",
"FailureReason": "Sequence Number is missing",
"MessageSubmissionTime": "Fri Mar 17 18:24:43.172 2017",
"MessageDeliveryTime": "Fri Mar 17 18:24:43.172 2017",
"RecordType": "DeliveryReceipt"
}

But its throwing the error while indexing
"reason": "Invalid format: \"Fri Mar 17 18:24:43.075 2017\""

Can you help how to put mappings for this type of dates????

Hey,

the format field is not supposed to be an array. Can you try "format": "EEE MMM dd HH:mm:ss.SSS yyyy"

--Alex

I remember somewhere I seen that data is an array. But thanks Its working fine now. Thanks

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