Update mapping for geoip.location


#1

Using Elasticsearch 2,2 I'm trying to update the field type for geoip.location (currently mapped as type 'number') to type geo_point using the following request:

myindex/_mapping/

{
  "properties": {
    "geoip.location": {
      "type": "geo_point"
    }
  }
}

Result is:

{
  "error": {
    "root_cause": [
      {
        "type": "mapper_parsing_exception",
        "reason": "Field name [geoip.location] cannot contain '.'"
      }
    ],
    "type": "mapper_parsing_exception",
    "reason": "Field name [geoip.location] cannot contain '.'"
  },
  "status": 400
}

Any ideas how I can do this?


(David Pilato) #2

Something like:

{
  "properties": {
    "geoip": {
      "type": "object",
      "properties": {
         "location": {
             "type": "geo_point"
        }
    }
  }
}

That said, elasticsearch will refuse to do it as you can't change an existing field. You'll have to create a new field or type or index and reindex.


#3

Ok, thanks. If I was to create a new template for this time based index, would it be like this?

{
    "template" : "myindex*",
    "settings" : {
        "number_of_shards" : 5
    },
"mappings": {
"properties" : {
"geoip": {
      "type": "object",
      "properties": {
         "location": {
             "type": "geo_point"
         }
       }
     }
   }
 }
}

(David Pilato) #4

Probably. I did not test it but it looks good.

Side note: please format your code when posting in discuss. It makes your posts more readable.


Geoip issues with ES 2.3.1
(system) #5