# Changing simple type mapping

**URL:** https://discuss.elastic.co/t/changing-simple-type-mapping/17698
**Category:** Elasticsearch
**Created:** [May 23, 2014, 4:09pm UTC](https://discuss.elastic.co/t/changing-simple-type-mapping/17698 "2014-05-23T16:09:37Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![Brian\_Lamb](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/brian_lamb/32/1452_2.png) [@Brian\_Lamb](https://discuss.elastic.co/u/Brian_Lamb)
#### Post date: [May 23, 2014, 4:09pm UTC](https://discuss.elastic.co/t/changing-simple-type-mapping/17698/1 "2014-05-23T16:09:37Z")

</div>

Hi all,

I need to change the mapping on one of my fields. It is currently an  
integer and I need it to be a string.

Ideally, I would be able to just change the type. But the documentation  
says that I cannot do that (unless that has changed in the last year, I  
think all the articles I read were at least a year old).

The next best suggestion I liked was changing the mapping to be a multi  
field. So I did the following:

curl -XPUT '[http://localhost:9200/myIndex/myType/\_mapping](http://localhost:9200/myIndex/myType/_mapping)' -d  
'{"myType":{"properties":{"copyrightYear":{"type":"multi\_field","fields":{"copyrightYear":{"type":"integer"},"textual":{"type":"string"}}}}}}'

But the result is:

curl -XGET '[http://localhost:9200/myIndex/\_mapping/myType](http://localhost:9200/myIndex/_mapping/myType)'  
{"myIndex":{"mappings":{"myType":{"index\_analyzer":"indexAnalyzer","search\_analyzer":"searchAnalyzer","\_boost":{"null\_value":1.0},"properties":{" **isInitialized**":{"type":"string"},,"copyrightYear":{"type":"integer","fields":{"copyrightYear":{"type":"integer"},"textual":{"type":"string"}}}

The issue is that when I try to add a document that has copyrightYear =  
'2013/2014' for example, I get an error:

Error in one or more bulk request actions:

index: /myIndex/myType/73148865 caused MapperParsingException[failed to  
parse [copyright.copyrightYear]]; nested: NumberFormatException[For input  
string: "2013/2014"];

Note that the adding uses the Elastica client but the error is due to the  
mapping. Is there a better approach to this problem? I don't really want to  
reindex all the things because I have about 22 million records.

Thanks!

Brian Lamb

--  
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).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/8adc6f39-85bd-4610-b354-8457b77b8cfd%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/8adc6f39-85bd-4610-b354-8457b77b8cfd%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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: [May 23, 2014, 4:50pm UTC](https://discuss.elastic.co/t/changing-simple-type-mapping/17698/2 "2014-05-23T16:50:34Z")

</div>

You need to reindex or you need to add a new field IMHO.

--  
David 😉  
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

> Le 23 mai 2014 à 18:09, Brian Lamb [brian.lamb@researchsquare.com](mailto:brian.lamb@researchsquare.com) a écrit :
> 
> Hi all,
> 
> I need to change the mapping on one of my fields. It is currently an integer and I need it to be a string.
> 
> Ideally, I would be able to just change the type. But the documentation says that I cannot do that (unless that has changed in the last year, I think all the articles I read were at least a year old).
> 
> The next best suggestion I liked was changing the mapping to be a multi field. So I did the following:
> 
> curl -XPUT '[http://localhost:9200/myIndex/myType/\_mapping](http://localhost:9200/myIndex/myType/_mapping)' -d '{"myType":{"properties":{"copyrightYear":{"type":"multi\_field","fields":{"copyrightYear":{"type":"integer"},"textual":{"type":"string"}}}}}}'
> 
> But the result is:
> 
> curl -XGET '[http://localhost:9200/myIndex/\_mapping/myType](http://localhost:9200/myIndex/_mapping/myType)'  
> {"myIndex":{"mappings":{"myType":{"index\_analyzer":"indexAnalyzer","search\_analyzer":"searchAnalyzer","\_boost":{"null\_value":1.0},"properties":{" **isInitialized**":{"type":"string"},,"copyrightYear":{"type":"integer","fields":{"copyrightYear":{"type":"integer"},"textual":{"type":"string"}}}
> 
> The issue is that when I try to add a document that has copyrightYear = '2013/2014' for example, I get an error:
> 
> Error in one or more bulk request actions:
> 
> index: /myIndex/myType/73148865 caused MapperParsingException[failed to parse [copyright.copyrightYear]]; nested: NumberFormatException[For input string: "2013/2014"];
> 
> Note that the adding uses the Elastica client but the error is due to the mapping. Is there a better approach to this problem? I don't really want to reindex all the things because I have about 22 million records.
> 
> Thanks!
> 
> ## Brian Lamb
> 
> 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).  
> To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/8adc6f39-85bd-4610-b354-8457b77b8cfd%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/8adc6f39-85bd-4610-b354-8457b77b8cfd%40googlegroups.com).  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
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).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/D6F67166-2DBD-419F-9F7D-3037C19B9428%40pilato.fr](https://groups.google.com/d/msgid/elasticsearch/D6F67166-2DBD-419F-9F7D-3037C19B9428%40pilato.fr).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

### Author: ![Clinton\_Gormley](https://avatars.discourse-cdn.com/v4/letter/c/50afbb/32.png) [@Clinton\_Gormley](https://discuss.elastic.co/u/Clinton_Gormley)
#### Post date: [May 23, 2014, 5:06pm UTC](https://discuss.elastic.co/t/changing-simple-type-mapping/17698/3 "2014-05-23T17:06:46Z")

</div>

Hi Brian

What you can do is to update the mapping of the numeric field to {  
ignore\_malformed: true }, then it will just ignore the bad data, but still  
use the multi-field:

```
PUT /my_index/my_type/1
{"number": 123}

PUT /my_index/_mapping/my_type
{
  "properties": {
    "number": {
      "type": "long",
      "ignore_malformed": true,
      "fields": {
        "string": {
          "type": "string"
        }
      }
    }
  }
}

PUT /my_index/my_type/1
{"number": "x"}

GET /_search
{
  "query": {
    "match": {
      "number.string": "x"
    }
  }
}

```

On 23 May 2014 18:09, Brian Lamb [brian.lamb@researchsquare.com](mailto:brian.lamb@researchsquare.com) wrote:

> Hi all,
> 
> I need to change the mapping on one of my fields. It is currently an  
> integer and I need it to be a string.
> 
> Ideally, I would be able to just change the type. But the documentation  
> says that I cannot do that (unless that has changed in the last year, I  
> think all the articles I read were at least a year old).
> 
> The next best suggestion I liked was changing the mapping to be a multi  
> field. So I did the following:
> 
> curl -XPUT '[http://localhost:9200/myIndex/myType/\_mapping](http://localhost:9200/myIndex/myType/_mapping)' -d  
> '{"myType":{"properties":{"copyrightYear":{"type":"multi\_field","fields":{"copyrightYear":{"type":"integer"},"textual":{"type":"string"}}}}}}'
> 
> But the result is:
> 
> curl -XGET '[http://localhost:9200/myIndex/\_mapping/myType](http://localhost:9200/myIndex/_mapping/myType)'
> 
> {"myIndex":{"mappings":{"myType":{"index\_analyzer":"indexAnalyzer","search\_analyzer":"searchAnalyzer","\_boost":{"null\_value":1.0},"properties":{" **isInitialized**":{"type":"string"},,"copyrightYear":{"type":"integer","fields":{"copyrightYear":{"type":"integer"},"textual":{"type":"string"}}}
> 
> The issue is that when I try to add a document that has copyrightYear =  
> '2013/2014' for example, I get an error:
> 
> Error in one or more bulk request actions:
> 
> index: /myIndex/myType/73148865 caused MapperParsingException[failed to  
> parse [copyright.copyrightYear]]; nested: NumberFormatException[For input  
> string: "2013/2014"];
> 
> Note that the adding uses the Elastica client but the error is due to the  
> mapping. Is there a better approach to this problem? I don't really want to  
> reindex all the things because I have about 22 million records.
> 
> Thanks!
> 
> Brian Lamb
> 
> --  
> 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).  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/8adc6f39-85bd-4610-b354-8457b77b8cfd%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/8adc6f39-85bd-4610-b354-8457b77b8cfd%40googlegroups.com)[https://groups.google.com/d/msgid/elasticsearch/8adc6f39-85bd-4610-b354-8457b77b8cfd%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/8adc6f39-85bd-4610-b354-8457b77b8cfd%40googlegroups.com?utm_medium=email&utm_source=footer)  
> .  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
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).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAPt3XKQnp6C6RrHC7FZG20s-Y%3DGp3zTrKZdzqCcsDjVDNBshKg%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAPt3XKQnp6C6RrHC7FZG20s-Y%3DGp3zTrKZdzqCcsDjVDNBshKg%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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: [May 23, 2014, 5:08pm UTC](https://discuss.elastic.co/t/changing-simple-type-mapping/17698/4 "2014-05-23T17:08:40Z")

</div>

w00t! Sounds like I missed that option.

Thanks Clint!

--  
David Pilato | Technical Advocate | [Elasticsearch.com](http://Elasticsearch.com)  
@dadoonet | @elasticsearchfr

Le 23 mai 2014 à 19:06:50, Clinton Gormley ([clint@traveljury.com](mailto:clint@traveljury.com)) a écrit:

Hi Brian

What you can do is to update the mapping of the numeric field to { ignore\_malformed: true }, then it will just ignore the bad data, but still use the multi-field:

```
PUT /my_index/my_type/1
{"number": 123}

PUT /my_index/_mapping/my_type
{
  "properties": {
    "number": {
      "type": "long",
      "ignore_malformed": true,
      "fields": {
        "string": {
          "type": "string"
        }
      }
    }
  }
}

PUT /my_index/my_type/1
{"number": "x"}

GET /_search
{
  "query": {
    "match": {
      "number.string": "x"
    }
  }
}

```

On 23 May 2014 18:09, Brian Lamb [brian.lamb@researchsquare.com](mailto:brian.lamb@researchsquare.com) wrote:  
Hi all,

I need to change the mapping on one of my fields. It is currently an integer and I need it to be a string.

Ideally, I would be able to just change the type. But the documentation says that I cannot do that (unless that has changed in the last year, I think all the articles I read were at least a year old).

The next best suggestion I liked was changing the mapping to be a multi field. So I did the following:

curl -XPUT '[http://localhost:9200/myIndex/myType/\_mapping](http://localhost:9200/myIndex/myType/_mapping)' -d '{"myType":{"properties":{"copyrightYear":{"type":"multi\_field","fields":{"copyrightYear":{"type":"integer"},"textual":{"type":"string"}}}}}}'

But the result is:

curl -XGET '[http://localhost:9200/myIndex/\_mapping/myType](http://localhost:9200/myIndex/_mapping/myType)'  
{"myIndex":{"mappings":{"myType":{"index\_analyzer":"indexAnalyzer","search\_analyzer":"searchAnalyzer","\_boost":{"null\_value":1.0},"properties":{" **isInitialized**":{"type":"string"},,"copyrightYear":{"type":"integer","fields":{"copyrightYear":{"type":"integer"},"textual":{"type":"string"}}}

The issue is that when I try to add a document that has copyrightYear = '2013/2014' for example, I get an error:

Error in one or more bulk request actions:

index: /myIndex/myType/73148865 caused MapperParsingException[failed to parse [copyright.copyrightYear]]; nested: NumberFormatException[For input string: "2013/2014"];

Note that the adding uses the Elastica client but the error is due to the mapping. Is there a better approach to this problem? I don't really want to reindex all the things because I have about 22 million records.

Thanks!

## Brian Lamb

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).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/8adc6f39-85bd-4610-b354-8457b77b8cfd%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/8adc6f39-85bd-4610-b354-8457b77b8cfd%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
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).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAPt3XKQnp6C6RrHC7FZG20s-Y%3DGp3zTrKZdzqCcsDjVDNBshKg%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAPt3XKQnp6C6RrHC7FZG20s-Y%3DGp3zTrKZdzqCcsDjVDNBshKg%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
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).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/etPan.537f8098.19495cff.1e56%40MacBook-Air-de-David.local](https://groups.google.com/d/msgid/elasticsearch/etPan.537f8098.19495cff.1e56%40MacBook-Air-de-David.local).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

### Author: ![Brian\_Lamb](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/brian_lamb/32/1452_2.png) [@Brian\_Lamb](https://discuss.elastic.co/u/Brian_Lamb)
#### Post date: [May 23, 2014, 9:07pm UTC](https://discuss.elastic.co/t/changing-simple-type-mapping/17698/5 "2014-05-23T21:07:56Z")

</div>

Hi Clinton,

Thank you for your suggestion. What will that do for the existing data?

Will I still be able to store copyrightYear as either a number or a string?

Thanks,

Brian Lamb

On Friday, May 23, 2014 1:09:46 PM UTC-4, David Pilato wrote:

> w00t! Sounds like I missed that option.
> 
> Thanks Clint!
> 
> --  
> _David Pilato_ | _Technical Advocate_ | _[Elasticsearch.com](http://Elasticsearch.com)_  
> @dadoonet [https://twitter.com/dadoonet](https://twitter.com/dadoonet) | @elasticsearchfr[https://twitter.com/elasticsearchfr](https://twitter.com/elasticsearchfr)
> 
> Le 23 mai 2014 à 19:06:50, Clinton Gormley ([cl...@traveljury.com](mailto:cl...@traveljury.com)\<javascript:\>)  
> a écrit:
> 
> Hi Brian
> 
> What you can do is to update the mapping of the numeric field to {  
> ignore\_malformed: true }, then it will just ignore the bad data, but still  
> use the multi-field:
> 
> ```
> PUT /my_index/my_type/1
> {"number": 123}
> 
> PUT /my_index/_mapping/my_type
> {
> "properties": {
> "number": {
> "type": "long",
> "ignore_malformed": true,
> "fields": {
> "string": {
> "type": "string"
> }
> }
> }
> }
> }
> 
> PUT /my_index/my_type/1
> {"number": "x"}
> 
> GET /_search
> {
> "query": {
> "match": {
> "number.string": "x"
> }
> }
> }
> 
> ```
> 
> On 23 May 2014 18:09, Brian Lamb \<[brian...@researchsquare.com](mailto:brian...@researchsquare.com)\<javascript:\>
> 
> > wrote:
> 
> > Hi all,
> > 
> > I need to change the mapping on one of my fields. It is currently an  
> > integer and I need it to be a string.
> > 
> > Ideally, I would be able to just change the type. But the documentation  
> > says that I cannot do that (unless that has changed in the last year, I  
> > think all the articles I read were at least a year old).
> > 
> > The next best suggestion I liked was changing the mapping to be a multi  
> > field. So I did the following:
> > 
> > curl -XPUT '[http://localhost:9200/myIndex/myType/\_mapping](http://localhost:9200/myIndex/myType/_mapping)' -d  
> > '{"myType":{"properties":{"copyrightYear":{"type":"multi\_field","fields":{"copyrightYear":{"type":"integer"},"textual":{"type":"string"}}}}}}'
> > 
> > But the result is:
> > 
> > curl -XGET '[http://localhost:9200/myIndex/\_mapping/myType](http://localhost:9200/myIndex/_mapping/myType)'
> > 
> > {"myIndex":{"mappings":{"myType":{"index\_analyzer":"indexAnalyzer","search\_analyzer":"searchAnalyzer","\_boost":{"null\_value":1.0},"properties":{" **isInitialized**":{"type":"string"},,"copyrightYear":{"type":"integer","fields":{"copyrightYear":{"type":"integer"},"textual":{"type":"string"}}}
> > 
> > The issue is that when I try to add a document that has copyrightYear =  
> > '2013/2014' for example, I get an error:
> > 
> > Error in one or more bulk request actions:
> > 
> > index: /myIndex/myType/73148865 caused MapperParsingException[failed to  
> > parse [copyright.copyrightYear]]; nested: NumberFormatException[For input  
> > string: "2013/2014"];
> > 
> > Note that the adding uses the Elastica client but the error is due to the  
> > mapping. Is there a better approach to this problem? I don't really want to  
> > reindex all the things because I have about 22 million records.
> > 
> > Thanks!
> > 
> > ## Brian Lamb
> > 
> > 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 [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com) \<javascript:\>.  
> > To view this discussion on the web visit  
> > [https://groups.google.com/d/msgid/elasticsearch/8adc6f39-85bd-4610-b354-8457b77b8cfd%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/8adc6f39-85bd-4610-b354-8457b77b8cfd%40googlegroups.com)[https://groups.google.com/d/msgid/elasticsearch/8adc6f39-85bd-4610-b354-8457b77b8cfd%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/8adc6f39-85bd-4610-b354-8457b77b8cfd%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > .  
> > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> 
> --  
> 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 [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com) \<javascript:\>.  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/CAPt3XKQnp6C6RrHC7FZG20s-Y%3DGp3zTrKZdzqCcsDjVDNBshKg%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAPt3XKQnp6C6RrHC7FZG20s-Y%3DGp3zTrKZdzqCcsDjVDNBshKg%40mail.gmail.com)[https://groups.google.com/d/msgid/elasticsearch/CAPt3XKQnp6C6RrHC7FZG20s-Y%3DGp3zTrKZdzqCcsDjVDNBshKg%40mail.gmail.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/CAPt3XKQnp6C6RrHC7FZG20s-Y%3DGp3zTrKZdzqCcsDjVDNBshKg%40mail.gmail.com?utm_medium=email&utm_source=footer)  
> .  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
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).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/44b6f6a9-5ac1-4f74-9eb5-66c2ec662022%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/44b6f6a9-5ac1-4f74-9eb5-66c2ec662022%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

### Author: ![Brian\_Lamb](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/brian_lamb/32/1452_2.png) [@Brian\_Lamb](https://discuss.elastic.co/u/Brian_Lamb)
#### Post date: [May 23, 2014, 9:08pm UTC](https://discuss.elastic.co/t/changing-simple-type-mapping/17698/6 "2014-05-23T21:08:38Z")

</div>

Hi Clinton,

Thank you for your suggestion. What will that do for the existing data?

Will I still be able to store copyrightYear as either a number or a string?

Thanks,

Brian Lamb

On Friday, May 23, 2014 1:09:46 PM UTC-4, David Pilato wrote:

> w00t! Sounds like I missed that option.
> 
> Thanks Clint!
> 
> --  
> _David Pilato_ | _Technical Advocate_ | _[Elasticsearch.com](http://Elasticsearch.com)_  
> @dadoonet [https://twitter.com/dadoonet](https://twitter.com/dadoonet) | @elasticsearchfr[https://twitter.com/elasticsearchfr](https://twitter.com/elasticsearchfr)
> 
> Le 23 mai 2014 à 19:06:50, Clinton Gormley ([cl...@traveljury.com](mailto:cl...@traveljury.com)\<javascript:\>)  
> a écrit:
> 
> Hi Brian
> 
> What you can do is to update the mapping of the numeric field to {  
> ignore\_malformed: true }, then it will just ignore the bad data, but still  
> use the multi-field:
> 
> ```
> PUT /my_index/my_type/1
> {"number": 123}
> 
> PUT /my_index/_mapping/my_type
> {
> "properties": {
> "number": {
> "type": "long",
> "ignore_malformed": true,
> "fields": {
> "string": {
> "type": "string"
> }
> }
> }
> }
> }
> 
> PUT /my_index/my_type/1
> {"number": "x"}
> 
> GET /_search
> {
> "query": {
> "match": {
> "number.string": "x"
> }
> }
> }
> 
> ```
> 
> On 23 May 2014 18:09, Brian Lamb \<[brian...@researchsquare.com](mailto:brian...@researchsquare.com)\<javascript:\>
> 
> > wrote:
> 
> > Hi all,
> > 
> > I need to change the mapping on one of my fields. It is currently an  
> > integer and I need it to be a string.
> > 
> > Ideally, I would be able to just change the type. But the documentation  
> > says that I cannot do that (unless that has changed in the last year, I  
> > think all the articles I read were at least a year old).
> > 
> > The next best suggestion I liked was changing the mapping to be a multi  
> > field. So I did the following:
> > 
> > curl -XPUT '[http://localhost:9200/myIndex/myType/\_mapping](http://localhost:9200/myIndex/myType/_mapping)' -d  
> > '{"myType":{"properties":{"copyrightYear":{"type":"multi\_field","fields":{"copyrightYear":{"type":"integer"},"textual":{"type":"string"}}}}}}'
> > 
> > But the result is:
> > 
> > curl -XGET '[http://localhost:9200/myIndex/\_mapping/myType](http://localhost:9200/myIndex/_mapping/myType)'
> > 
> > {"myIndex":{"mappings":{"myType":{"index\_analyzer":"indexAnalyzer","search\_analyzer":"searchAnalyzer","\_boost":{"null\_value":1.0},"properties":{" **isInitialized**":{"type":"string"},,"copyrightYear":{"type":"integer","fields":{"copyrightYear":{"type":"integer"},"textual":{"type":"string"}}}
> > 
> > The issue is that when I try to add a document that has copyrightYear =  
> > '2013/2014' for example, I get an error:
> > 
> > Error in one or more bulk request actions:
> > 
> > index: /myIndex/myType/73148865 caused MapperParsingException[failed to  
> > parse [copyright.copyrightYear]]; nested: NumberFormatException[For input  
> > string: "2013/2014"];
> > 
> > Note that the adding uses the Elastica client but the error is due to the  
> > mapping. Is there a better approach to this problem? I don't really want to  
> > reindex all the things because I have about 22 million records.
> > 
> > Thanks!
> > 
> > ## Brian Lamb
> > 
> > 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 [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com) \<javascript:\>.  
> > To view this discussion on the web visit  
> > [https://groups.google.com/d/msgid/elasticsearch/8adc6f39-85bd-4610-b354-8457b77b8cfd%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/8adc6f39-85bd-4610-b354-8457b77b8cfd%40googlegroups.com)[https://groups.google.com/d/msgid/elasticsearch/8adc6f39-85bd-4610-b354-8457b77b8cfd%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/8adc6f39-85bd-4610-b354-8457b77b8cfd%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > .  
> > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> 
> --  
> 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 [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com) \<javascript:\>.  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/CAPt3XKQnp6C6RrHC7FZG20s-Y%3DGp3zTrKZdzqCcsDjVDNBshKg%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAPt3XKQnp6C6RrHC7FZG20s-Y%3DGp3zTrKZdzqCcsDjVDNBshKg%40mail.gmail.com)[https://groups.google.com/d/msgid/elasticsearch/CAPt3XKQnp6C6RrHC7FZG20s-Y%3DGp3zTrKZdzqCcsDjVDNBshKg%40mail.gmail.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/CAPt3XKQnp6C6RrHC7FZG20s-Y%3DGp3zTrKZdzqCcsDjVDNBshKg%40mail.gmail.com?utm_medium=email&utm_source=footer)  
> .  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
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).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/aac85e1c-7f89-4a1e-b293-490a67e9f43b%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/aac85e1c-7f89-4a1e-b293-490a67e9f43b%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

### Author: ![Clinton\_Gormley](https://avatars.discourse-cdn.com/v4/letter/c/50afbb/32.png) [@Clinton\_Gormley](https://discuss.elastic.co/u/Clinton_Gormley)
#### Post date: [May 23, 2014, 9:34pm UTC](https://discuss.elastic.co/t/changing-simple-type-mapping/17698/7 "2014-05-23T21:34:13Z")

</div>

> Thank you for your suggestion. What will that do for the existing data?
> 
> Will I still be able to store copyrightYear as either a number or a string?

It won't change any existing data. However, for data you index in the  
future it will index either a number and a string, or (if it can't coerce  
the value into a number), just a string, eg: if you index these two docs:

{ "copyrightYear": "2010"}  
{ "copyrightYear": "2011/2012"}

then "copyrightYear" will contain 2010, and "copyrightYear.textual" will  
contain "2010", "2011", "2012"

> 

--  
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).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAPt3XKRr5CLjRL1D\_FtHbewaJWz2%3DoNC5j403zwwtvWNk28eqA%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAPt3XKRr5CLjRL1D_FtHbewaJWz2%3DoNC5j403zwwtvWNk28eqA%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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, 1:27am UTC](https://discuss.elastic.co/t/changing-simple-type-mapping/17698/8 "2017-07-06T01:27:17Z")

</div>


