# Date pattern specified is mapping not applied

**URL:** <https://discuss.elastic.co/t/date-pattern-specified-is-mapping-not-applied/13759>\
**Category:** Elasticsearch\
**Created:** [September 25, 2013, 9:42pm UTC](https://discuss.elastic.co/t/date-pattern-specified-is-mapping-not-applied/13759 "2013-09-25T21:42:25Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ram\_Viswanadha](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ram_viswanadha/32/1888_2.png) [@Ram\_Viswanadha](https://discuss.elastic.co/u/Ram_Viswanadha)\
**Post date:** [September 25, 2013, 9:42pm UTC](https://discuss.elastic.co/t/date-pattern-specified-is-mapping-not-applied/13759/1 "2013-09-25T21:42:25Z")

</div>

I have events coming in that have interesting date formats. I set up the  
pattern to be accepted in the mapping of the index. But, I am getting the  
following errors  
curl -XPOST  
'[http://localhost:9200/events\_addon\_20130925/topbar?pretty=true](http://localhost:9200/events_addon_20130925/topbar?pretty=true)' -d  
'{"url": "[http://money-on-mobile.net/index.aspx](http://money-on-mobile.net/index.aspx)", "install\_date": "Sun Sep  
15 2013 16:41:53 GMT+0530 (India Standard Time)", "state": "close", "bfp":  
"1008244289", "event\_date": "Sun Sep 22 2013 20:03:46 GMT+0530 (India  
Standard Time)", "browser": "chrome"}'  
{  
"error" : "MapperParsingException[failed to parse [install\_date]];  
nested: MapperParsingException[failed to parse date field [Sun Sep 15 2013  
16:41:53 GMT+0530 (India Standard Time)], tried both date format [EEE MMM  
dd yyyy HH:mm:ss 'GMT'Z (zzzz)], and timestamp number with locale [null]];  
nested: UnsupportedOperationException[Parsing not supported]; ",  
"status" : 400  
}

Here is the mapping I applied

$ curl -XGET  
'[http://localhost:9200/events\_addon\_20130925/topbar/\_mapping?pretty=true](http://localhost:9200/events_addon_20130925/topbar/_mapping?pretty=true)'  
{  
"topbar" : {  
"properties" : {  
"bfp" : {  
"type" : "string",  
"index" : "not\_analyzed",  
"omit\_norms" : true,  
"index\_options" : "docs"  
},  
"browser" : {  
"type" : "string"  
},  
"event\_date" : {  
"type" : "date",  
"format" : "EEE MMM dd yyyy HH:mm:ss 'GMT'Z (zzzz)"  
},  
"install\_date" : {  
"type" : "date",  
"format" : "EEE MMM dd yyyy HH:mm:ss 'GMT'Z (zzzz)"  
},  
"state" : {  
"type" : "string"  
},  
"url" : {  
"type" : "string"  
},  
"version\_number" : {  
"type" : "string",  
"index" : "not\_analyzed",  
"omit\_norms" : true,  
"index\_options" : "docs"  
}  
}  
}  
}

I tested the pattern using SimpleDateFormat in Java and it works. Not sure  
what I am doing wrong in ElasticSearch. Any idea?

$ JAVA\_HOME=/usr/lib/jvm/java-7-openjdk-amd64/ java Test "EEE MMM dd yyyy  
HH:mm:ss 'GMT'Z (zzzz)" "Sun Sep 22 2013 20:03:46 GMT+0530 (India Standard  
Time)"  
The formatted string: Wed Sep 25 2013 21:41:00 GMT+0000 (Coordinated  
Universal Time)  
The parsed date is: Wed Sep 25 2013 21:41:00 GMT+0000 (Coordinated  
Universal Time)  
The parsed date from input is: Sun Sep 22 2013 20:03:46 GMT+0530 (India  
Standard Time)

import java.text.SimpleDateFormat;  
import java.util.Date;

public class Test{  
public static void main(String[] args) {  
String pattern=args[0];  
String dtstr = args[1];  
SimpleDateFormat sdf = new SimpleDateFormat(pattern);  
Date date = new Date();  
try {  
//  
String fmtd = sdf.format(date);  
System.out.println("The formatted string: " +fmtd);  
System.out.println("The parsed date is: " +  
sdf.format(sdf.parse(fmtd)));  
System.out.println("The parsed date from input is: " +  
sdf.format(sdf.parse(dtstr)));  
} catch (Exception e) {  
e.printStackTrace();  
}  
}  
}

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Ram\_Viswanadha](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ram_viswanadha/32/1888_2.png) [@Ram\_Viswanadha](https://discuss.elastic.co/u/Ram_Viswanadha)\
**Post date:** [September 26, 2013, 10:07pm UTC](https://discuss.elastic.co/t/date-pattern-specified-is-mapping-not-applied/13759/2 "2013-09-26T22:07:48Z")

</div>

Figured this one out. Joda Time does not support parsing of long timezone  
identifiers. So, need to change the data in 6M records 🙂

On Wednesday, September 25, 2013 2:42:25 PM UTC-7, Ram Viswanadha wrote:

> I have events coming in that have interesting date formats. I set up the  
> pattern to be accepted in the mapping of the index. But, I am getting the  
> following errors  
> curl -XPOST '  
> [http://localhost:9200/events\_addon\_20130925/topbar?pretty=true](http://localhost:9200/events_addon_20130925/topbar?pretty=true)' -d  
> '{"url": "[http://money-on-mobile.net/index.aspx](http://money-on-mobile.net/index.aspx)", "install\_date": "Sun  
> Sep 15 2013 16:41:53 GMT+0530 (India Standard Time)", "state": "close",  
> "bfp": "1008244289", "event\_date": "Sun Sep 22 2013 20:03:46 GMT+0530  
> (India Standard Time)", "browser": "chrome"}'  
> {  
> "error" : "MapperParsingException[failed to parse [install\_date]];  
> nested: MapperParsingException[failed to parse date field [Sun Sep 15 2013  
> 16:41:53 GMT+0530 (India Standard Time)], tried both date format [EEE MMM  
> dd yyyy HH:mm:ss 'GMT'Z (zzzz)], and timestamp number with locale [null]];  
> nested: UnsupportedOperationException[Parsing not supported]; ",  
> "status" : 400  
> }
> 
> Here is the mapping I applied
> 
> $ curl -XGET '  
> [http://localhost:9200/events\_addon\_20130925/topbar/\_mapping?pretty=true](http://localhost:9200/events_addon_20130925/topbar/_mapping?pretty=true)'  
> {  
> "topbar" : {  
> "properties" : {  
> "bfp" : {  
> "type" : "string",  
> "index" : "not\_analyzed",  
> "omit\_norms" : true,  
> "index\_options" : "docs"  
> },  
> "browser" : {  
> "type" : "string"  
> },  
> "event\_date" : {  
> "type" : "date",  
> "format" : "EEE MMM dd yyyy HH:mm:ss 'GMT'Z (zzzz)"  
> },  
> "install\_date" : {  
> "type" : "date",  
> "format" : "EEE MMM dd yyyy HH:mm:ss 'GMT'Z (zzzz)"  
> },  
> "state" : {  
> "type" : "string"  
> },  
> "url" : {  
> "type" : "string"  
> },  
> "version\_number" : {  
> "type" : "string",  
> "index" : "not\_analyzed",  
> "omit\_norms" : true,  
> "index\_options" : "docs"  
> }  
> }  
> }  
> }
> 
> I tested the pattern using SimpleDateFormat in Java and it works. Not sure  
> what I am doing wrong in Elasticsearch. Any idea?
> 
> $ JAVA\_HOME=/usr/lib/jvm/java-7-openjdk-amd64/ java Test "EEE MMM dd yyyy  
> HH:mm:ss 'GMT'Z (zzzz)" "Sun Sep 22 2013 20:03:46 GMT+0530 (India Standard  
> Time)"  
> The formatted string: Wed Sep 25 2013 21:41:00 GMT+0000 (Coordinated  
> Universal Time)  
> The parsed date is: Wed Sep 25 2013 21:41:00 GMT+0000 (Coordinated  
> Universal Time)  
> The parsed date from input is: Sun Sep 22 2013 20:03:46 GMT+0530 (India  
> Standard Time)
> 
> import java.text.SimpleDateFormat;  
> import java.util.Date;
> 
> public class Test{  
> public static void main(String args) {  
> String pattern=args[0];  
> String dtstr = args[1];  
> SimpleDateFormat sdf = new SimpleDateFormat(pattern);  
> Date date = new Date();  
> try {  
> //  
> String fmtd = sdf.format(date);  
> System.out.println("The formatted string: " +fmtd);  
> System.out.println("The parsed date is: " +  
> sdf.format(sdf.parse(fmtd)));  
> System.out.println("The parsed date from input is: " +  
> sdf.format(sdf.parse(dtstr)));  
> } catch (Exception e) {  
> e.printStackTrace();  
> }  
> }  
> }

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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:** [July 6, 2017, 2:14am UTC](https://discuss.elastic.co/t/date-pattern-specified-is-mapping-not-applied/13759/3 "2017-07-06T02:14:29Z")

</div>

Closed on July 6, 2017, 2:14am UTC


