# Datatype long behaving odd

**URL:** <https://discuss.elastic.co/t/datatype-long-behaving-odd/7679>\
**Category:** Elasticsearch\
**Created:** [May 14, 2012, 10:51am UTC](https://discuss.elastic.co/t/datatype-long-behaving-odd/7679 "2012-05-14T10:51:53Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![narinder\_izap](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/narinder_izap/32/803_2.png) [@narinder\_izap](https://discuss.elastic.co/u/narinder_izap)\
**Post date:** [May 14, 2012, 10:51am UTC](https://discuss.elastic.co/t/datatype-long-behaving-odd/7679/1 "2012-05-14T10:51:53Z")

</div>

hey shay,  
I am confused with the long datatype.

I have a document of type "posts":

{  
id: int  
title:string  
owner\_id:int  
can\_view: array  
{  
type:long  
}  
}

Here in this "can\_view" attributes was saving the ids of the users who can  
view the posts,and data which was stored was like :

{  
id: 2343  
title:"my post for all"  
owner\_id:123  
can\_view: array  
[  
2324,  
2343,  
"7654"  
]  
}

like here some ids are stored as int and some as _string_, and it was  
working fine. I did'nt get how was this happening. as java is strict  
language,so it should not allow the int saved as string(int number with  
quotes).

and now i need to change the data, instead of saving the ids, i have to  
store the names, but its giving the exception

_"MapperParsingException[Failed to parse [can\_see]]; nested:  
NumberFormatException[For input string: "narinder"]; "_  
\*  
\*  
And moreover we are having a plan to store mixed datatypes in the single  
level array, is that possible?? please help me through.

Thanks

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [May 15, 2012, 8:38pm UTC](https://discuss.elastic.co/t/datatype-long-behaving-odd/7679/2 "2012-05-15T20:38:25Z")

</div>

Once a field is of numeric type (int or long for example, which differ on  
the number of bytes used to represent them), then it will also support  
providing a "string" value that can be parsed to the numeric value. The  
first data type of the document introduced will be used if its not mapped  
explicitly. Once the data type of a field is set, it can't be changed.

If you have a field that has both numeric and text values, then it can be a  
string type.

On Mon, May 14, 2012 at 1:51 PM, Narinder Kaur [narinder.kaur@izap.in](mailto:narinder.kaur@izap.in)wrote:

> hey shay,  
> I am confused with the long datatype.
> 
> I have a document of type "posts":
> 
> {  
> id: int  
> title:string  
> owner\_id:int  
> can\_view: array  
> {  
> type:long  
> }  
> }
> 
> Here in this "can\_view" attributes was saving the ids of the users who can  
> view the posts,and data which was stored was like :
> 
> {  
> id: 2343  
> title:"my post for all"  
> owner\_id:123  
> can\_view: array  
> [  
> 2324,  
> 2343,  
> "7654"  
> ]  
> }
> 
> like here some ids are stored as int and some as _string_, and it was  
> working fine. I did'nt get how was this happening. as java is strict  
> language,so it should not allow the int saved as string(int number with  
> quotes).
> 
> and now i need to change the data, instead of saving the ids, i have to  
> store the names, but its giving the exception
> 
> _"MapperParsingException[Failed to parse [can\_see]]; nested:  
> NumberFormatException[For input string: "narinder"]; "_  
> \*  
> \*  
> And moreover we are having a plan to store mixed datatypes in the single  
> level array, is that possible?? please help me through.
> 
> Thanks

---

<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, 3:28am UTC](https://discuss.elastic.co/t/datatype-long-behaving-odd/7679/3 "2017-07-06T03:28:41Z")

</div>


