We have a dynamic field defined in multiple indexes that is of type geo_shape
, and uses the points_only
param. Due to a) the deprecation of points_only
in version 7.x, and b) the fact that we don't use that field any more, we want to remove it from the mapping and the data, although the mapping is the most important, since we don't search on that field.
First, here is the mapping definition:
"mappings": {
"dynamic_templates": [
{
"base_geo": {
"match": "*Geo",
"mapping": {
"points_only": true,
"type": "geo_shape"
}
}
},
...
]
}
It appears that the Reindex API can be used to do this, since in order to remove a field from a mapping, a new index has to be created. As such, I've been trying variations on this to POST _reindex
{
"source": {
"index": "local_federal_agency_models_1708127195"
},
"dest": {
"index": "local_federal_agency_models_1708127195_3"
},
"script": {
"source": "ctx._source.remove('base_geo')"
}
}
However, this not only removes the base_geo
field, but it removes the entire dynamic_templates
array, so it removes all dynamic mappings.
As for the documents themselves, I know I can use an ingest pipeline, but how can I just remove my base_geo
field mapping when re-indexing?