# Elasticsearch mapping update

**URL:** <https://discuss.elastic.co/t/elasticsearch-mapping-update/63470>\
**Category:** Elasticsearch\
**Created:** [October 20, 2016, 6:34am UTC](https://discuss.elastic.co/t/elasticsearch-mapping-update/63470 "2016-10-20T06:34:31Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hilal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/hilal/32/7684_2.png) [@Hilal](https://discuss.elastic.co/u/Hilal)\
**Post date:** [October 20, 2016, 6:34am UTC](https://discuss.elastic.co/t/elasticsearch-mapping-update/63470/1 "2016-10-20T06:34:31Z")

</div>

Hi,  
I indexed my mysql datas with ES but my "year" field mapping was wrong.  
How do I update my mapping?

My mapping:

```
PUT my_index/my_type/_mapping
{
"properties" : {
"Year" : {
"type" : "date", 
"format" : "yyyy-MM-dd"
} 

```

The format was wrong. Actually it should be this way:

```
PUT my_index/my_type/_mapping
{
"properties" : {
"Year" : {
"type" : "date", 
"format" : "yyyy"
} 

```

What can I do?

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [October 20, 2016, 6:51am UTC](https://discuss.elastic.co/t/elasticsearch-mapping-update/63470/2 "2016-10-20T06:51:26Z")

</div>

You have to reindex.

But if you indexed your data already what is wrong then?  
Can you explain why the current format you have does not suit your use case?

---

<div class="post-metadata">

**Author:** ![Hilal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/hilal/32/7684_2.png) [@Hilal](https://discuss.elastic.co/u/Hilal)\
**Post date:** [October 20, 2016, 7:03am UTC](https://discuss.elastic.co/t/elasticsearch-mapping-update/63470/3 "2016-10-20T07:03:27Z")

</div>

For example `year = "2015`" but It was indexed `format : yyyy-MM-dd.` It have to be `format : yyyy`

I get an error when I query:

```
{
   "error": {
      "root_cause": [
         {
            "type": "illegal_argument_exception",
            "reason": "Invalid format: \"2015\" is too short"
         }
      ],
      "type": "search_phase_execution_exception",
      "reason": "all shards failed",
      "phase": "query",
      "grouped": true,
      "failed_shards": [
         {
            "shard": 0,
            "index": "titub",
            "node": "93UU8PfmSR6TZQdClhmhIg",
            "reason": {
               "type": "illegal_argument_exception",
               "reason": "Invalid format: \"2015\" is too short"
            }
         }
      ]
   },
   "status": 400
}

```

It indexed the total data size is 2.5 GB. Data takes too long to re-indexed. Because I carry the Elasticsearch technology from my MySQL data using PHP

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [October 20, 2016, 7:37am UTC](https://discuss.elastic.co/t/elasticsearch-mapping-update/63470/4 "2016-10-20T07:37:56Z")

</div>

How did you manage to index older data then if they were not using that format `YYYY`?

---

<div class="post-metadata">

**Author:** ![Hilal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/hilal/32/7684_2.png) [@Hilal](https://discuss.elastic.co/u/Hilal)\
**Post date:** [October 20, 2016, 10:50am UTC](https://discuss.elastic.co/t/elasticsearch-mapping-update/63470/5 "2016-10-20T10:50:15Z")

</div>

you are right. Then the query may be incorrect.

---

<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 5, 2017, 10:10pm UTC](https://discuss.elastic.co/t/elasticsearch-mapping-update/63470/6 "2017-07-05T22:10:55Z")

</div>


