# How to stop ElasticSearch from doing type casting?

**URL:** <https://discuss.elastic.co/t/how-to-stop-elasticsearch-from-doing-type-casting/41836>\
**Category:** Elasticsearch\
**Created:** [February 16, 2016, 4:57am UTC](https://discuss.elastic.co/t/how-to-stop-elasticsearch-from-doing-type-casting/41836 "2016-02-16T04:57:25Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![anjith.p](https://avatars.discourse-cdn.com/v4/letter/a/a3d4f5/32.png) [@anjith.p](https://discuss.elastic.co/u/anjith.p)\
**Post date:** [February 16, 2016, 4:57am UTC](https://discuss.elastic.co/t/how-to-stop-elasticsearch-from-doing-type-casting/41836/1 "2016-02-16T04:57:25Z")

</div>

I've a field,let's say f1,with type "String" in an index. Now, if I send integer data into field f1, ES is converting the value to String - normally this is the accepted behavior. But in our case we need to prevent this from happening. I'm wondering if there is any seetting which disabled implicit type conversion.

---

<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:** [February 16, 2016, 5:26am UTC](https://discuss.elastic.co/t/how-to-stop-elasticsearch-from-doing-type-casting/41836/2 "2016-02-16T05:26:05Z")

</div>

Unsure about what you want to achieve but a single field can not be at the same time a String or a number.

---

<div class="post-metadata">

**Author:** ![anjith.p](https://avatars.discourse-cdn.com/v4/letter/a/a3d4f5/32.png) [@anjith.p](https://discuss.elastic.co/u/anjith.p)\
**Post date:** [February 16, 2016, 5:36am UTC](https://discuss.elastic.co/t/how-to-stop-elasticsearch-from-doing-type-casting/41836/3 "2016-02-16T05:36:54Z")

</div>

Agreed that ES 2.0 doesn't supprt 2 fields with a same name and different types. These are my scenarios:

1. indexed field f1 with int type: later sent field f1 with string - threw exception, which is expected.
2. indexed field f1 with string type: later sent field f1 with int- no exception, casted int to string, which we want to avoid.

---

<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:** [February 16, 2016, 5:51am UTC](https://discuss.elastic.co/t/how-to-stop-elasticsearch-from-doing-type-casting/41836/4 "2016-02-16T05:51:11Z")

</div>

I don't think we have such option so you should do that on client side.

---

<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, 11:16pm UTC](https://discuss.elastic.co/t/how-to-stop-elasticsearch-from-doing-type-casting/41836/5 "2017-07-05T23:16:08Z")

</div>


