# Update date field format mapping

**URL:** <https://discuss.elastic.co/t/update-date-field-format-mapping/13924>\
**Category:** Elasticsearch\
**Created:** [October 11, 2013, 11:31am UTC](https://discuss.elastic.co/t/update-date-field-format-mapping/13924 "2013-10-11T11:31:06Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Matthias\_Gotzke](https://avatars.discourse-cdn.com/v4/letter/m/6f9a4e/32.png) [@Matthias\_Gotzke](https://discuss.elastic.co/u/Matthias_Gotzke)\
**Post date:** [October 11, 2013, 11:31am UTC](https://discuss.elastic.co/t/update-date-field-format-mapping/13924/1 "2013-10-11T11:31:06Z")

</div>

Since the format used in the mapping of a field also seems to be used for  
interpreting query\_string queries. Is it possible to update the format of a  
mapped date field to include alternate representations ?

eg.

{  
"person": {  
"properties": {  
"birthDate": {  
"type": "date",  
"format": "YYYYMMdd"  
}  
}  
}  
}

to

{  
"person": {  
"properties": {  
"birthDate": {  
"type": "date",  
"format": "YYYYMMdd||dd.MM.yyyy"  
}  
}  
}  
}

Since this would not change the way data is parsed/stored etc it should not  
require a re-index of any kind.

When trying to update a mapping this way though it returns { "ok":true,  
"acknowledge":true} without doing anything.

On a related note, I see the query\_string parser seems to use the  
DateMathParser.java class. This class sadly uses hardcoded string for  
specifiers such as w or y for week and year respectively. Any chance to  
make this configurable ? Either globally or per request.

--  
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:** ![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:** [October 14, 2013, 7:49am UTC](https://discuss.elastic.co/t/update-date-field-format-mapping/13924/2 "2013-10-14T07:49:09Z")

</div>

Hey Matthias,

I am not a hundred percent sure I got your questions, so let me try:

1. You would like to change the date format on the fly if I got you right.  
I have a PR lying around for that, where I still need to sort some things  
out, see [DateFieldMapper.merge() can change date format and include\_in\_all by spinscale · Pull Request #3735 · elastic/elasticsearch · GitHub](https://github.com/elasticsearch/elasticsearch/pull/3735) if you  
are interested. This also means, once a date format is set, you cannot  
change it at the moment.

2. You lost me here. What exactly would you like to configure? The  
representation for week/year? Can you tell me a bit more about your  
use-case so I understand?

Thx and sorry for the confusion on my side.

--Alex

On Fri, Oct 11, 2013 at 1:31 PM, Matthias Götzke [mgt576@gmail.com](mailto:mgt576@gmail.com) wrote:

> Since the format used in the mapping of a field also seems to be used for  
> interpreting query\_string queries. Is it possible to update the format of a  
> mapped date field to include alternate representations ?
> 
> eg.
> 
> {  
> "person": {  
> "properties": {  
> "birthDate": {  
> "type": "date",  
> "format": "YYYYMMdd"  
> }  
> }  
> }  
> }
> 
> to
> 
> {  
> "person": {  
> "properties": {  
> "birthDate": {  
> "type": "date",  
> "format": "YYYYMMdd||dd.MM.yyyy"  
> }  
> }  
> }  
> }
> 
> Since this would not change the way data is parsed/stored etc it should  
> not require a re-index of any kind.
> 
> When trying to update a mapping this way though it returns { "ok":true,  
> "acknowledge":true} without doing anything.
> 
> On a related note, I see the query\_string parser seems to use the  
> DateMathParser.java class. This class sadly uses hardcoded string for  
> specifiers such as w or y for week and year respectively. Any chance to  
> make this configurable ? Either globally or per request.
> 
> --  
> 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).

--  
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:** ![Matthias\_Gotzke](https://avatars.discourse-cdn.com/v4/letter/m/6f9a4e/32.png) [@Matthias\_Gotzke](https://discuss.elastic.co/u/Matthias_Gotzke)\
**Post date:** [October 14, 2013, 10:14am UTC](https://discuss.elastic.co/t/update-date-field-format-mapping/13924/3 "2013-10-14T10:14:47Z")

</div>

Hi,

Will have a look the pr...

1. the letters y m d etc are English abbreviations .. In other languages  
that would naturally be something else.

E.g 4/23/2013-1y is us English... In German it should be 23.4.2013-1j .. J  
instead of y

## Von meinem Windows Phone gesendet

From: Alexander Reelsen [alr@spinscale.de](mailto:alr@spinscale.de)  
Sent: 14.10.2013 09:49  
To: [elasticsearch@googlegroups.com](mailto:elasticsearch@googlegroups.com)  
Subject: Re: Update date field format mapping

Hey Matthias,

I am not a hundred percent sure I got your questions, so let me try:

1. You would like to change the date format on the fly if I got you right.  
I have a PR lying around for that, where I still need to sort some things  
out, see [DateFieldMapper.merge() can change date format and include\_in\_all by spinscale · Pull Request #3735 · elastic/elasticsearch · GitHub](https://github.com/elasticsearch/elasticsearch/pull/3735) if you  
are interested. This also means, once a date format is set, you cannot  
change it at the moment.

2. You lost me here. What exactly would you like to configure? The  
representation for week/year? Can you tell me a bit more about your  
use-case so I understand?

Thx and sorry for the confusion on my side.

--Alex

On Fri, Oct 11, 2013 at 1:31 PM, Matthias Götzke [mgt576@gmail.com](mailto:mgt576@gmail.com) wrote:

> Since the format used in the mapping of a field also seems to be used for  
> interpreting query\_string queries. Is it possible to update the format of a  
> mapped date field to include alternate representations ?
> 
> eg.
> 
> {  
> "person": {  
> "properties": {  
> "birthDate": {  
> "type": "date",  
> "format": "YYYYMMdd"  
> }  
> }  
> }  
> }
> 
> to
> 
> {  
> "person": {  
> "properties": {  
> "birthDate": {  
> "type": "date",  
> "format": "YYYYMMdd||dd.MM.yyyy"  
> }  
> }  
> }  
> }
> 
> Since this would not change the way data is parsed/stored etc it should  
> not require a re-index of any kind.
> 
> When trying to update a mapping this way though it returns { "ok":true,  
> "acknowledge":true} without doing anything.
> 
> On a related note, I see the query\_string parser seems to use the  
> DateMathParser.java class. This class sadly uses hardcoded string for  
> specifiers such as w or y for week and year respectively. Any chance to  
> make this configurable ? Either globally or per request.
> 
> --  
> 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).

--  
You received this message because you are subscribed to a topic in the  
Google Groups "elasticsearch" group.  
To unsubscribe from this topic, visit  
[https://groups.google.com/d/topic/elasticsearch/cf\_hTbj4MhM/unsubscribe](https://groups.google.com/d/topic/elasticsearch/cf_hTbj4MhM/unsubscribe).  
To unsubscribe from this group and all its topics, 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).

--  
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:12am UTC](https://discuss.elastic.co/t/update-date-field-format-mapping/13924/4 "2017-07-06T02:12:36Z")

</div>


