How to change the json objects mapping to geo_point

HI,

i'm using elk stack of version 7.1.1 with x-pack installed

and I have follwing json data in elasticsearch

{
   "id":"someid",
   "geometry":{
      "type": "Point",
      "coordinates":[
         -76,
         -10
      ]
   },

and the mapping of this data is the following

   "geometry" : {
          "properties" : {
            "coordinates" : {
              "type" : "long"
            },
            "type" : {
              "type" : "text",
              "fields" : {
                "keyword" : {
                  "type" : "keyword",
                  "ignore_above" : 256
                }
              }
            }
          }
        },

so
How to change the geometry.coordinates type to geo_point ?

i tried the following and its showing errors

PUT jsongeo-maps/
{
 "mappings": {
      "geometry": {
        "properties":{
          "coordinates":{ "type": "geo_point" }
     }
    }
   } 
} 

and im getting the followwing errors :

"type": "resource_already_exists_exception",
    "reason": "index [jsongeo-maps/Ciit7Q1lQ8eqhcf32NDuhA] already exists",
    "index_uuid": "Ciit7Q1lQ8eqhcf32NDuhA",
    "index": "jsongeo-maps"
  },

so i deleted the index and added the mapping first then im getting the following error

{
      "error": {
        "root_cause": [
          {
            "type": "mapper_parsing_exception",
            "reason": "Root mapping definition has unsupported parameters:  [geometry : {properties={coordinates={type=geo_point}}}]"
          }
        ],
        "type": "mapper_parsing_exception",
        "reason": "Failed to parse mapping [_doc]: Root mapping definition has unsupported parameters:  [geometry : {properties={coordinates={type=geo_point}}}]",
        "caused_by": {
          "type": "mapper_parsing_exception",
          "reason": "Root mapping definition has unsupported parameters:  [geometry : {properties={coordinates={type=geo_point}}}]"
        }
      },
      "status": 400
    }

Please help me solve it ?

You were right that you had to delete the index first - it is not possible to change an existing mapping of a field. The reason the index creation with your mapping fails, is because the request is malformed. Try the following instead:

PUT jsongeo-maps/
{
  "mappings": {
    "properties": {
      "geometry": {
        "properties": {
          "coordinates": {
            "type": "geo_point"
          }
        }
      }
    }
  }
} 

Thanks @abdon it worked !

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.