# Geo\_point mapped field is returned as string in java api

**URL:** <https://discuss.elastic.co/t/geo-point-mapped-field-is-returned-as-string-in-java-api/21042>\
**Category:** Elasticsearch\
**Created:** [December 2, 2014, 8:15pm UTC](https://discuss.elastic.co/t/geo-point-mapped-field-is-returned-as-string-in-java-api/21042 "2014-12-02T20:15:01Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![T\_Vinod\_Gupta](https://avatars.discourse-cdn.com/v4/letter/t/fbc32d/32.png) [@T\_Vinod\_Gupta](https://discuss.elastic.co/u/T_Vinod_Gupta)\
**Post date:** [December 2, 2014, 8:15pm UTC](https://discuss.elastic.co/t/geo-point-mapped-field-is-returned-as-string-in-java-api/21042/1 "2014-12-02T20:15:01Z")

</div>

has anyone seen this problem? my mapping says that the field is of type  
geo\_point. but when i read documents using java api and get the sourcemap,  
the type of the field is string and i can't cast it to a GeoPoint.

...  
"lat\_lng" : {  
"type" : "geo\_point",  
"lat\_lon" : true  
},  
..

thanks

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAHau4ysRanZ%3DsO8zKJjDDx4tpSnG1zcXnXhHB4cfnbOyQkvXoQ%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAHau4ysRanZ%3DsO8zKJjDDx4tpSnG1zcXnXhHB4cfnbOyQkvXoQ%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Nicholas\_Knize](https://avatars.discourse-cdn.com/v4/letter/n/76d3ee/32.png) [@Nicholas\_Knize](https://discuss.elastic.co/u/Nicholas_Knize)\
**Post date:** [December 4, 2014, 2:32pm UTC](https://discuss.elastic.co/t/geo-point-mapped-field-is-returned-as-string-in-java-api/21042/2 "2014-12-04T14:32:04Z")

</div>

Can you post a code example from your use case for how you're inserting,  
retrieving, and reading the documents?

- Nick

On Tuesday, December 2, 2014 2:16:30 PM UTC-6, T Vinod Gupta wrote:

> has anyone seen this problem? my mapping says that the field is of type  
> geo\_point. but when i read documents using java api and get the sourcemap,  
> the type of the field is string and i can't cast it to a GeoPoint.
> 
> ...  
> "lat\_lng" : {  
> "type" : "geo\_point",  
> "lat\_lon" : true  
> },  
> ..
> 
> thanks

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/b5ed03a4-eaad-491b-9856-087ae3ab2587%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/b5ed03a4-eaad-491b-9856-087ae3ab2587%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![T\_Vinod\_Gupta](https://avatars.discourse-cdn.com/v4/letter/t/fbc32d/32.png) [@T\_Vinod\_Gupta](https://discuss.elastic.co/u/T_Vinod_Gupta)\
**Post date:** [December 4, 2014, 6:04pm UTC](https://discuss.elastic.co/t/geo-point-mapped-field-is-returned-as-string-in-java-api/21042/3 "2014-12-04T18:04:04Z")

</div>

nevermind, i solved it by doing something like this -  
GeoPoint latLng = GeoPoint.parseFromLatLon((String)  
sourceMap.get("lat\_lng"));

at the time of indexing, i am passing as ","

earlier i was passing as GeoPoint but that caused a major problem and  
messed up my mapping. When i read the document and then change some other  
field and do index, then it would raise this exception -  
ElasticsearchParseException("field must be either '" + LATITUDE + "', '" +  
LONGITUDE + "' or '" + GEOHASH + "'");

so i figured that indexing by passing the string (even though mapping is  
geo\_point) works.  
thanks

On Thu, Dec 4, 2014 at 6:32 AM, Nicholas Knize \<  
[nicholas.knize@elasticsearch.com](mailto:nicholas.knize@elasticsearch.com)\> wrote:

> Can you post a code example from your use case for how you're inserting,  
> retrieving, and reading the documents?
> 
> - Nick
> 
> On Tuesday, December 2, 2014 2:16:30 PM UTC-6, T Vinod Gupta wrote:
> 
> > has anyone seen this problem? my mapping says that the field is of type  
> > geo\_point. but when i read documents using java api and get the sourcemap,  
> > the type of the field is string and i can't cast it to a GeoPoint.
> > 
> > ...  
> > "lat\_lng" : {  
> > "type" : "geo\_point",  
> > "lat\_lon" : true  
> > },  
> > ..
> > 
> > thanks
> 
> --  
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/b5ed03a4-eaad-491b-9856-087ae3ab2587%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/b5ed03a4-eaad-491b-9856-087ae3ab2587%40googlegroups.com)  
> [https://groups.google.com/d/msgid/elasticsearch/b5ed03a4-eaad-491b-9856-087ae3ab2587%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/b5ed03a4-eaad-491b-9856-087ae3ab2587%40googlegroups.com?utm_medium=email&utm_source=footer)  
> .  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAHau4yvDyp5uO\_bhj%3DFwNtNB\_fPu9sHpbKfb-OMr4hBygL8bfQ%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAHau4yvDyp5uO_bhj%3DFwNtNB_fPu9sHpbKfb-OMr4hBygL8bfQ%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Nicholas\_Knize](https://avatars.discourse-cdn.com/v4/letter/n/76d3ee/32.png) [@Nicholas\_Knize](https://discuss.elastic.co/u/Nicholas_Knize)\
**Post date:** [December 4, 2014, 6:19pm UTC](https://discuss.elastic.co/t/geo-point-mapped-field-is-returned-as-string-in-java-api/21042/4 "2014-12-04T18:19:29Z")

</div>

Glad to hear you resolved your issue. Let us know if you have any other  
questions.

- Nick

On Thursday, December 4, 2014 12:04:14 PM UTC-6, T Vinod Gupta wrote:

> nevermind, i solved it by doing something like this -  
> GeoPoint latLng = GeoPoint.parseFromLatLon((String)  
> sourceMap.get("lat\_lng"));
> 
> at the time of indexing, i am passing as ","
> 
> earlier i was passing as GeoPoint but that caused a major problem and  
> messed up my mapping. When i read the document and then change some other  
> field and do index, then it would raise this exception -  
> ElasticsearchParseException("field must be either '" + LATITUDE + "', '" +  
> LONGITUDE + "' or '" + GEOHASH + "'");
> 
> so i figured that indexing by passing the string (even though mapping is  
> geo\_point) works.  
> thanks
> 
> On Thu, Dec 4, 2014 at 6:32 AM, Nicholas Knize \<  
> [nichola...@elasticsearch.com](mailto:nichola...@elasticsearch.com) \<javascript:\>\> wrote:
> 
> > Can you post a code example from your use case for how you're inserting,  
> > retrieving, and reading the documents?
> > 
> > - Nick
> > 
> > On Tuesday, December 2, 2014 2:16:30 PM UTC-6, T Vinod Gupta wrote:
> > 
> > > has anyone seen this problem? my mapping says that the field is of type  
> > > geo\_point. but when i read documents using java api and get the sourcemap,  
> > > the type of the field is string and i can't cast it to a GeoPoint.
> > > 
> > > ...  
> > > "lat\_lng" : {  
> > > "type" : "geo\_point",  
> > > "lat\_lon" : true  
> > > },  
> > > ..
> > > 
> > > thanks
> > 
> > --  
> > You received this message because you are subscribed to the Google Groups  
> > "elasticsearch" group.  
> > To unsubscribe from this group and stop receiving emails from it, send an  
> > email to [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com) \<javascript:\>.  
> > To view this discussion on the web visit  
> > [https://groups.google.com/d/msgid/elasticsearch/b5ed03a4-eaad-491b-9856-087ae3ab2587%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/b5ed03a4-eaad-491b-9856-087ae3ab2587%40googlegroups.com)  
> > [https://groups.google.com/d/msgid/elasticsearch/b5ed03a4-eaad-491b-9856-087ae3ab2587%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/b5ed03a4-eaad-491b-9856-087ae3ab2587%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > .  
> > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/138a1355-7815-4afa-915d-924332ce494a%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/138a1355-7815-4afa-915d-924332ce494a%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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, 12:45am UTC](https://discuss.elastic.co/t/geo-point-mapped-field-is-returned-as-string-in-java-api/21042/5 "2017-07-06T00:45:52Z")

</div>


