# How to convert a field from type long to double

**URL:** <https://discuss.elastic.co/t/how-to-convert-a-field-from-type-long-to-double/17510>\
**Category:** Elasticsearch\
**Created:** [May 14, 2014, 10:47am UTC](https://discuss.elastic.co/t/how-to-convert-a-field-from-type-long-to-double/17510 "2014-05-14T10:47:24Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Saurabh\_Minni](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/saurabh_minni/32/1103_2.png) [@Saurabh\_Minni](https://discuss.elastic.co/u/Saurabh_Minni)\
**Post date:** [May 14, 2014, 10:47am UTC](https://discuss.elastic.co/t/how-to-convert-a-field-from-type-long-to-double/17510/1 "2014-05-14T10:47:24Z")

</div>

Hi,  
I wanted to get a list of results sorted by a particular field. I am  
getting the following error on search from kibana on this.

{  
"error" : "ReduceSearchPhaseException[Failed to execute phase [query],  
[reduce] ]; nested: ClassCastException; ",  
"status" : 503  
}

I checked this particular field and found that its been auto mapped to Long  
when it should have been Double. Is there any way in which I can covert  
these fields to Double and also prevent such a thing from happening in the  
future.

Thanks,  
Saurabh

--  
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/0869c7f7-72a3-4326-b44d-39f01f7e1d47%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/0869c7f7-72a3-4326-b44d-39f01f7e1d47%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![ElasticSearch\_Users\_](https://avatars.discourse-cdn.com/v4/letter/e/b4bc9f/32.png) [@ElasticSearch\_Users\_](https://discuss.elastic.co/u/ElasticSearch_Users_)\
**Post date:** [May 14, 2014, 1:41pm UTC](https://discuss.elastic.co/t/how-to-convert-a-field-from-type-long-to-double/17510/2 "2014-05-14T13:41:59Z")

</div>

If you are indexing the content yourself, then you can define the field  
type in your mapping prior to indexing. If you are using Logstash to do the  
indexing, you can define your own index template, and then reference it  
from your logstash elasticsearch output using the template/template\_name  
properties. Either way, you will unfortunately need to delete the existing  
data with the incorrect type and reindex again using your new mappings.

--  
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/4516196f-047c-4822-a78f-9f818a463ddf%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/4516196f-047c-4822-a78f-9f818a463ddf%40googlegroups.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:29am UTC](https://discuss.elastic.co/t/how-to-convert-a-field-from-type-long-to-double/17510/3 "2017-07-06T01:29:29Z")

</div>


