1
votes

As the guide stated, https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-geo-point-type.html#_mapping_options

I could use an array of lat/lon variables, and map it to geo_point type.

so here is my current mapping:

{
   "zoek": {
      "mappings": {
         "geo": {
            "properties": {
               "country": {
                  "type": "string"
               },
               "geonameid": {
                  "type": "string"
               },
               "locatie": {
                  "type": "double"
               },
               "name": {
                  "type": "string"
               }
            }
         }
      }
   }
}

"locatie" refers to an array of two double. [ lat, lon ].

I want to map this to the geo_point variable to perform geo distance queries.

so i tried this:

PUT /zoek/geo/_mapping 
{
    "geo" : {
        "properties" : {
            "locatie" : {"type" : "geo_point" }
        }
    }
}

and got this error:

{
   "error": "MergeMappingException[Merge failed with failures {[mapper [locatie] of different type, current_type [double], merged_type [geo_point]]}]",

"status": 400 }

Any suggestions?

Greets,

Dagmar.

1

1 Answers

2
votes

In a given mapping type (i.e. geo), you cannot define two fields with the same name (i.e. locatie) but a different type (i.e. one as double and another as geo_point). Since you already have a field name locatie in your geo mapping type, you cannot add a new one with the same name, but you can definitely add another with a different name, e.g. location_geo.

However, I suggest changing your original mapping and replace your locatie (as double) with locatie (as geo_point). If you do so, you'll need to reindex your existing data, though, so that might not be an option for you.