# SearchHit.sourceAsMap() maps longs as integer

**URL:** <https://discuss.elastic.co/t/searchhit-sourceasmap-maps-longs-as-integer/4668>\
**Category:** Elasticsearch\
**Created:** [June 21, 2011, 7:32am UTC](https://discuss.elastic.co/t/searchhit-sourceasmap-maps-longs-as-integer/4668 "2011-06-21T07:32:56Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![cnotin](https://avatars.discourse-cdn.com/v4/letter/c/aca169/32.png) [@cnotin](https://discuss.elastic.co/u/cnotin)\
**Post date:** [June 21, 2011, 7:32am UTC](https://discuss.elastic.co/t/searchhit-sourceasmap-maps-longs-as-integer/4668/1 "2011-06-21T07:32:56Z")

</div>

Hello,

In ES I have a field of type long, confirmed by  
curl -XGET '[http://clem-vbox:9200/sicap/abo/\_mapping?pretty=true](http://clem-vbox:9200/sicap/abo/_mapping?pretty=true)

But when I query ES and get the first SearchHit's map with :  
hit.sourceAsMap().get("xxx"));

It returns me an Integer (and my test fails !) instead of Long.

Is it normal ?  
Thx

---

<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:** [June 21, 2011, 7:59am UTC](https://discuss.elastic.co/t/searchhit-sourceasmap-maps-longs-as-integer/4668/2 "2011-06-21T07:59:54Z")

</div>

Yes, thats what the json parsing does. When you index a document in elasticsearch, it gets translated to json and indexed, when you ask for it, it gets parsed back.

On Tuesday, June 21, 2011 at 10:32 AM, cnotin wrote:

> Hello,
> 
> In ES I have a field of type long, confirmed by  
> curl -XGET '[http://clem-vbox:9200/sicap/abo/\_mapping?pretty=true](http://clem-vbox:9200/sicap/abo/_mapping?pretty=true)
> 
> But when I query ES and get the first SearchHit's map with :  
> hit.sourceAsMap().get("xxx"));
> 
> It returns me an Integer (and my test fails !) instead of Long.
> 
> Is it normal ?  
> Thx
> 
> --  
> View this message in context: [http://elasticsearch-users.115913.n3.nabble.com/SearchHit-sourceAsMap-maps-longs-as-integer-tp3089616p3089616.html](http://elasticsearch-users.115913.n3.nabble.com/SearchHit-sourceAsMap-maps-longs-as-integer-tp3089616p3089616.html)  
> Sent from the Elasticsearch Users mailing list archive at [Nabble.com](http://Nabble.com) ([http://Nabble.com](http://Nabble.com)).

---

<div class="post-metadata">

**Author:** ![cnotin](https://avatars.discourse-cdn.com/v4/letter/c/aca169/32.png) [@cnotin](https://discuss.elastic.co/u/cnotin)\
**Post date:** [June 21, 2011, 8:02am UTC](https://discuss.elastic.co/t/searchhit-sourceasmap-maps-longs-as-integer/4668/3 "2011-06-21T08:02:00Z")

</div>

Ok so I assume that if a document contains a very long Int it will be parsed as Long.  
Thx

---

<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, 4:03am UTC](https://discuss.elastic.co/t/searchhit-sourceasmap-maps-longs-as-integer/4668/4 "2017-07-06T04:03:03Z")

</div>


