In later Elasticsearch versions (7.x), types were removed. Updating a mapping can becomes:
curl -XPUT "http://localhost:9200/test/_mapping" -H 'Content-Type: application/json' -d'{
"properties": {
"new_geo_field": {
"type": "geo_point"
}
}
}'
As others have pointed out, if the field exists, you typically have to reindex. There are exceptions, such as adding a new sub-field or changing analysis settings.
You can't "create a mapping", as the mapping is created with the index. Typically, you'd define the mapping when creating the index (or via index templates):
curl -XPUT "http://localhost:9200/test" -H 'Content-Type: application/json' -d'{
"mappings": {
"properties": {
"foo_field": {
"type": "text"
}
}
}
}'
That's because, in production at least, you'd want to avoid letting Elasticsearch "guess" new fields. Which is what generated this question: geo data was read as an array of long
values.