# Date mapping in elasticsearch

**URL:** <https://discuss.elastic.co/t/date-mapping-in-elasticsearch/79208>\
**Category:** Elasticsearch\
**Created:** [March 20, 2017, 7:32am UTC](https://discuss.elastic.co/t/date-mapping-in-elasticsearch/79208 "2017-03-20T07:32:45Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ravi\_Shanker\_Reddy](https://avatars.discourse-cdn.com/v4/letter/r/a5b964/32.png) [@Ravi\_Shanker\_Reddy](https://discuss.elastic.co/u/Ravi_Shanker_Reddy)\
**Post date:** [March 20, 2017, 7:32am UTC](https://discuss.elastic.co/t/date-mapping-in-elasticsearch/79208/1 "2017-03-20T07:32:45Z")

</div>

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????

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [March 20, 2017, 8:38am UTC](https://discuss.elastic.co/t/date-mapping-in-elasticsearch/79208/2 "2017-03-20T08:38:42Z")

</div>

Hey,

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

--Alex

---

<div class="post-metadata">

**Author:** ![Ravi\_Shanker\_Reddy](https://avatars.discourse-cdn.com/v4/letter/r/a5b964/32.png) [@Ravi\_Shanker\_Reddy](https://discuss.elastic.co/u/Ravi_Shanker_Reddy)\
**Post date:** [March 20, 2017, 8:50am UTC](https://discuss.elastic.co/t/date-mapping-in-elasticsearch/79208/3 "2017-03-20T08:50:44Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [April 17, 2017, 8:51am UTC](https://discuss.elastic.co/t/date-mapping-in-elasticsearch/79208/4 "2017-04-17T08:51:12Z")

</div>

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