# Change/update of the datatype of latitude and longitude from double to geo\_points

**URL:** https://discuss.elastic.co/t/change-update-of-the-datatype-of-latitude-and-longitude-from-double-to-geo-points/22849
**Category:** Elasticsearch
**Created:** [March 24, 2015, 9:39am UTC](https://discuss.elastic.co/t/change-update-of-the-datatype-of-latitude-and-longitude-from-double-to-geo-points/22849 "2015-03-24T09:39:34Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![nidhi\_chawhan](https://avatars.discourse-cdn.com/v4/letter/n/d78d45/32.png) [@nidhi\_chawhan](https://discuss.elastic.co/u/nidhi_chawhan)
#### Post date: [March 24, 2015, 9:39am UTC](https://discuss.elastic.co/t/change-update-of-the-datatype-of-latitude-and-longitude-from-double-to-geo-points/22849/1 "2015-03-24T09:39:34Z")

</div>

Hi Team,

I wanted to update the datatype of latitude and longitude fields from  
double to geo\_points .

Index name :- visit.hippo\_en  
Type :- visit:PlaceDocument

PUT /visit.hippo\_en/visit:PlaceDocument/\_mapping  
{  
"location": {  
"properties" :{  
"coordinates": {  
"properties":{  
"coordinates": {  
"properties":{  
"latitude": {  
"type": "geo\_point"

```
                 },
                 "longitude": {
                    "type": "geo_point"
                   
                 }
             }
          }
             
      }
    }
  }

```

}  
}

then getting below error

{  
"error": "MapperParsingException[Root type mapping not empty after  
parsing! Remaining fields: [location :  
{properties={coordinates={properties={coordinates={properties={latitude={type=geo\_point},  
longitude={type=geo\_point}}}}}}}]]",  
"status": 400  
}

when trying to update through java API  
below is the code

CreateIndex createIndex = new CreateIndex.Builder(visitHippoIndexName +  
UNDERSCORE + lang).build();  
jestClient.execute(createIndex);

String geoPointMapping = "\n" +  
" "location": {\n" +  
" "properties" :{\n" +  
" "coordinates": {\n" +  
" "properties":{\n" +  
" "coordinates": {\n" +  
" "properties":{ \n" +  
" "latitude": {\n" +  
" "type": "geo\_point"\n" +  
" \n" +  
" },\n" +  
" "longitude": {\n" +  
" "type": "geo\_point"\n" +  
" \n" +  
" }\n" +  
" }\n" +  
" }\n" +  
" \n" +  
" }\n" +  
" }\n" +  
" }\n" +  
" }";

if(nodeType.equals("visit:PlaceDocument")){  
PutMapping keyMapping = new PutMapping.Builder(visitHippoIndexName +  
UNDERSCORE + lang, nodeType, geoPointMapping).build();  
jestClient.execute(keyMapping);  
}

Index index = new Index.Builder(source).index(visitHippoIndexName +  
UNDERSCORE + lang).type(nodeType).id(handleNode.getIdentifier()).build();  
jestClient.execute(index);

It gives me below exception

2015-03-24 10:27:13,787][DEBUG][action.admin.indices.mapping.put]  
[Carnivore] failed to put mappings on indices [[visit.hi  
po\_en]], type [visit:PlaceDocument]  
rg.elasticsearch.index.mapper.MapperParsingException: malformed mapping no  
root object found  
at  
org.elasticsearch.index.mapper.DocumentMapperParser.extractMapping(DocumentMapperParser.java:338)  
at  
org.elasticsearch.index.mapper.DocumentMapperParser.parseCompressed(DocumentMapperParser.java:183)  
at  
org.elasticsearch.index.mapper.MapperService.parse(MapperService.java:444)  
at  
org.elasticsearch.cluster.metadata.MetaDataMappingService$4.execute(MetaDataMappingService.java:505)  
at  
org.elasticsearch.cluster.service.InternalClusterService$UpdateTask.run(InternalClusterService.java:329)  
at  
org.elasticsearch.common.util.concurrent.PrioritizedEsThreadPoolExecutor$TieBreakingPrioritizedRunnable.run(Prio  
itizedEsThreadPoolExecutor.java:153)  
at  
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)  
at  
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)  
at java.lang.Thread.run(Thread.java:745)

i am giving the root object which is location in this case.  
But still error.

Please advise how to update the double object to geopoints?

Thanks,  
Nidhi

--  
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/776927e3-e551-4269-bf17-962134a4b17a%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/776927e3-e551-4269-bf17-962134a4b17a%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

### Author: ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)
#### Post date: [March 24, 2015, 9:50am UTC](https://discuss.elastic.co/t/change-update-of-the-datatype-of-latitude-and-longitude-from-double-to-geo-points/22849/2 "2015-03-24T09:50:07Z")

</div>

1: you can not « update » an existing field and transform it from double to geo\_points  
2: you want coordinates to be your geo\_point, not latitude and longitude to be each of it a geo\_point.  
3: your put mapping request is incorrect. Have a look at [Update mapping API | Elasticsearch Guide [8.11] | Elastic](http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-put-mapping.html) [http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-put-mapping.html](http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-put-mapping.html)  
The type should be part of your JSON content.

HTH

--  
David Pilato - Developer | Evangelist

> **[Elasticsearch Platform — Find real-time answers at scale](https://www.elastic.co/)**
>
> Power insights and outcomes with the Elasticsearch Platform and AI. See into your data and find answers that matter with enterprise solutions designed to help you build, observe, and protect. Try Elasticsearch free today.

@dadoonet [https://twitter.com/dadoonet](https://twitter.com/dadoonet) | @elasticsearchfr [https://twitter.com/elasticsearchfr](https://twitter.com/elasticsearchfr) | @scrutmydocs [https://twitter.com/scrutmydocs](https://twitter.com/scrutmydocs)

> Le 24 mars 2015 à 10:39, nidhi chawhan [nidhi.chawhan@gmail.com](mailto:nidhi.chawhan@gmail.com) a écrit :
> 
> Hi Team,
> 
> I wanted to update the datatype of latitude and longitude fields from double to geo\_points .
> 
> Index name :- visit.hippo\_en  
> Type :- visit:PlaceDocument
> 
> PUT /visit.hippo\_en/visit:PlaceDocument/\_mapping  
> {  
> "location": {  
> "properties" :{  
> "coordinates": {  
> "properties":{  
> "coordinates": {  
> "properties":{  
> "latitude": {  
> "type": "geo\_point"
> 
> ```
> },
> "longitude": {
> "type": "geo_point"
>                    
> }
> }
> }
>              
> }
> }
> }
> 
> ```
> 
> }  
> }
> 
> then getting below error
> 
> {  
> "error": "MapperParsingException[Root type mapping not empty after parsing! Remaining fields: [location : {properties={coordinates={properties={coordinates={properties={latitude={type=geo\_point}, longitude={type=geo\_point}}}}}}}]]",  
> "status": 400  
> }
> 
> when trying to update through java API  
> below is the code
> 
> CreateIndex createIndex = new CreateIndex.Builder(visitHippoIndexName + UNDERSCORE + lang).build();  
> jestClient.execute(createIndex);
> 
> ```
> String geoPointMapping = "\n" +
> " \"location\": {\n" +
> " \"properties\" :{\n" +
> " \"coordinates\": {\n" +
> " \"properties\":{\n" +
> " \"coordinates\": {\n" +
> " \"properties\":{ \n" +
> " \"latitude\": {\n" +
> " \"type\": \"geo_point\"\n" +
> " \n" +
> " },\n" +
> " \"longitude\": {\n" +
> " \"type\": \"geo_point\"\n" +
> " \n" +
> " }\n" +
> " }\n" +
> " }\n" +
> " \n" +
> " }\n" +
> " }\n" +
> " }\n" +
> " }";
> 
> if(nodeType.equals("visit:PlaceDocument")){
> PutMapping keyMapping = new PutMapping.Builder(visitHippoIndexName + UNDERSCORE + lang, nodeType, geoPointMapping).build();
> jestClient.execute(keyMapping);
> }
> 
> Index index = new Index.Builder(source).index(visitHippoIndexName + UNDERSCORE + lang).type(nodeType).id(handleNode.getIdentifier()).build();
> jestClient.execute(index);
> 
> ```
> 
> It gives me below exception
> 
> 2015-03-24 10:27:13,787][DEBUG][action.admin.indices.mapping.put] [Carnivore] failed to put mappings on indices [[visit.hi  
> po\_en]], type [visit:PlaceDocument]  
> rg.elasticsearch.index.mapper.MapperParsingException: malformed mapping no root object found  
> at org.elasticsearch.index.mapper.DocumentMapperParser.extractMapping(DocumentMapperParser.java:338)  
> at org.elasticsearch.index.mapper.DocumentMapperParser.parseCompressed(DocumentMapperParser.java:183)  
> at org.elasticsearch.index.mapper.MapperService.parse(MapperService.java:444)  
> at org.elasticsearch.cluster.metadata.MetaDataMappingService$4.execute(MetaDataMappingService.java:505)  
> at org.elasticsearch.cluster.service.InternalClusterService$UpdateTask.run(InternalClusterService.java:329)  
> at org.elasticsearch.common.util.concurrent.PrioritizedEsThreadPoolExecutor$TieBreakingPrioritizedRunnable.run(Prio  
> itizedEsThreadPoolExecutor.java:153)  
> at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)  
> at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)  
> at java.lang.Thread.run(Thread.java:745)
> 
> i am giving the root object which is location in this case.  
> But still error.
> 
> Please advise how to update the double object to geopoints?
> 
> Thanks,  
> Nidhi
> 
> --  
> 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) [mailto:elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/776927e3-e551-4269-bf17-962134a4b17a%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/776927e3-e551-4269-bf17-962134a4b17a%40googlegroups.com) [https://groups.google.com/d/msgid/elasticsearch/776927e3-e551-4269-bf17-962134a4b17a%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/776927e3-e551-4269-bf17-962134a4b17a%40googlegroups.com?utm_medium=email&utm_source=footer).  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout) [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/6142BB21-A45A-4CF1-88DA-0F55B21E3D70%40pilato.fr](https://groups.google.com/d/msgid/elasticsearch/6142BB21-A45A-4CF1-88DA-0F55B21E3D70%40pilato.fr).  
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:24am UTC](https://discuss.elastic.co/t/change-update-of-the-datatype-of-latitude-and-longitude-from-double-to-geo-points/22849/3 "2017-07-06T00:24:32Z")

</div>


