Change/update of the datatype of latitude and longitude from double to geo_points

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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/776927e3-e551-4269-bf17-962134a4b17a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

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
The type should be part of your JSON content.

HTH

--
David Pilato - Developer | Evangelist

@dadoonet https://twitter.com/dadoonet | @elasticsearchfr https://twitter.com/elasticsearchfr | @scrutmydocs https://twitter.com/scrutmydocs

Le 24 mars 2015 à 10:39, nidhi chawhan 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.
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?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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/6142BB21-A45A-4CF1-88DA-0F55B21E3D70%40pilato.fr.
For more options, visit https://groups.google.com/d/optout.