无论如何,我可以在现有的Elasticsearch映射中重命名元素而不必添加新元素?如果是这样,为了避免破坏现有映射,最好的方法是什么?
例如从fieldCamelcase到fieldCamelCase
{ "myType": { "properties": { "timestamp": { "type": "date", "format": "date_optional_time" }, "fieldCamelcase": { "type": "string", "index": "not_analyzed" }, "field_test": { "type": "double" } } } }
您可以通过创建一个Ingest管道来做到这一点,该管道包含一个Rename Processor和Reindex API。
PUT _ingest/pipeline/my_rename_pipeline { "description" : "describe pipeline", "processors" : [ { "rename": { "field": "fieldCamelcase", "target_field": "fieldCamelCase" } } ] } POST _reindex { "source": { "index": "source" }, "dest": { "index": "dest", "pipeline": "my_rename_pipeline" } }
请注意,您需要运行Elasticsearch 5.x才能使用摄取。如果您运行的是<5.x,那么您必须使用他评论中提到的@Val :)