1

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 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

2 Comments

curl -XPUT localhost:9200/zoek/geo/0 -d ' { "geonameid" : "2743463", "name" : "Den Oord", "locatie" : [ 51.9708300, 5.2708300], "country" : "NL" } ';
How do you change the original mapping? I tried this and got a similar error mapper [source.geoip.coordinates] of different type, current_type [double], merged_type [geo_point]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.