來自于 stackoverflow Elasticsearch Mapping - Rename existing field
You could do this by creating an Ingest pipeline, that contains a Rename Processor in combination with the 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"
}
}
這種操作赊瞬,會新建一個index塑径,并不是直接在原來的索引的基礎上進行直接修改字段名辽狈。
而且在最終執(zhí)行時候像街,會有這種問題
{
"took": 1170,
"timed_out": false,
"total": 111500,
"updated": 0,
"created": 971,
"deleted": 0,
"batches": 1,
"version_conflicts": 0,
"noops": 0,
"retries": {
"bulk": 0,
"search": 0
},
"throttled_millis": 0,
"requests_per_second": -1,
"throttled_until_millis": 0,
"failures": [
{
"index": "case-info-new-test",
"type": "case_info",
"id": "5beae7d0264f4b001bea7d46",
"cause": {
"type": "exception",
"reason": "java.lang.IllegalArgumentException: java.lang.IllegalArgumentException: field [case_owner_id] doesn't exist",
"caused_by": {
"type": "illegal_argument_exception",
"reason": "java.lang.IllegalArgumentException: field [case_owner_id] doesn't exist",
"caused_by": {
"type": "illegal_argument_exception",
"reason": "field [case_owner_id] doesn't exist"
}
},
"header": {
"processor_type": "rename"
}
},
"status": 500
},
{
"index": "case-info-new-test",
"type": "case_info",
"id": "5beaa0125c94560014527e92",
"cause": {
"type": "exception",
"reason": "java.lang.IllegalArgumentException: java.lang.IllegalArgumentException: field [case_owner_id] doesn't exist",
"caused_by": {
"type": "illegal_argument_exception",
"reason": "java.lang.IllegalArgumentException: field [case_owner_id] doesn't exist",
"caused_by": {
"type": "illegal_argument_exception",
"reason": "field [case_owner_id] doesn't exist"
}
},
"header": {
"processor_type": "rename"
}
},
"status": 500
}
]
}