# Uncertain field types when extracting fields from org.elasticsearch.search.SearchHit.getSource()

**URL:** <https://discuss.elastic.co/t/uncertain-field-types-when-extracting-fields-from-org-elasticsearch-search-searchhit-getsource/10431>\
**Category:** Elasticsearch\
**Created:** [January 20, 2013, 7:33pm UTC](https://discuss.elastic.co/t/uncertain-field-types-when-extracting-fields-from-org-elasticsearch-search-searchhit-getsource/10431 "2013-01-20T19:33:45Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Burak\_Emre\_Kabakci](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/burak_emre_kabakci/32/2212_2.png) [@Burak\_Emre\_Kabakci](https://discuss.elastic.co/u/Burak_Emre_Kabakci)\
**Post date:** [January 20, 2013, 7:33pm UTC](https://discuss.elastic.co/t/uncertain-field-types-when-extracting-fields-from-org-elasticsearch-search-searchhit-getsource/10431/1 "2013-01-20T19:33:45Z")

</div>

I'm trying to extract fields from  
org.elasticsearch.search.SearchHit.getSource() but I'm having difficulties  
of determining types of fields. For example I have a field named rank defined  
as long with \_mapping and when I extract it from Map\<String, Object\> I  
couldn't be able to cast it Long because it returns as java.lang.Double or  
java.lang.Integer. I encountered same problem for short type and it returns  
as java.lang.Integer

--

---

<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, 2:55am UTC](https://discuss.elastic.co/t/uncertain-field-types-when-extracting-fields-from-org-elasticsearch-search-searchhit-getsource/10431/2 "2017-07-06T02:55:28Z")

</div>


