# Long type field is getting converted to integer

**URL:** <https://discuss.elastic.co/t/long-type-field-is-getting-converted-to-integer/136886>\
**Category:** Elasticsearch\
**Created:** [June 21, 2018, 1:41pm UTC](https://discuss.elastic.co/t/long-type-field-is-getting-converted-to-integer/136886 "2018-06-21T13:41:57Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![siddharth\_jain](https://avatars.discourse-cdn.com/v4/letter/s/b77776/32.png) [@siddharth\_jain](https://discuss.elastic.co/u/siddharth_jain)\
**Post date:** [June 21, 2018, 1:41pm UTC](https://discuss.elastic.co/t/long-type-field-is-getting-converted-to-integer/136886/1 "2018-06-21T13:41:57Z")

</div>

I have a field id which is stored as long.  
The mapping is -

> "id": {  
> "type": "long",  
> "store": true  
> },

If the value of id is small and I retrieve the id it is returning an integer type data, which is causing a Class cast exception.  
If the value is large it returns a long type data.  
Is there any way I can force the data type to be long

---

<div class="post-metadata">

**Author:** ![cbuescher](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cbuescher/32/60402_2.png) [@cbuescher](https://discuss.elastic.co/u/cbuescher)\
**Post date:** [June 29, 2018, 12:43pm UTC](https://discuss.elastic.co/t/long-type-field-is-getting-converted-to-integer/136886/2 "2018-06-29T12:43:36Z")

</div>

Which client are you using?

---

<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 27, 2018, 12:43pm UTC](https://discuss.elastic.co/t/long-type-field-is-getting-converted-to-integer/136886/3 "2018-07-27T12:43:40Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
