elasticsearch rename existing field

来自于 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,并不是直接在原来的索引的基础上进行直接修改字段名。

而且在最终执行时候,会有这种问题

{
  "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
    }
  ]
}
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • !/usr/bin/env python -- coding: utf-8 -- '''根据某个traceId去调...
    小七奇奇阅读 639评论 0 0
  • 外力内在形股力 压抑内心纠缠结放下放空宁静心 静净明心明意心 冷酷无情似冷血 看似无情真有情放空思想放下心 ...
    東風唐阅读 207评论 0 0
  • 昨日儿童节,宋慧乔现身中环出席某著名腕表新品发表会以及新店开幕礼。活动一开始,她就以韩语与在场人士打招呼,表示自己...
    青雨阅读 582评论 0 0
  • 别人的四十岁 能在一个雨天 开着豪车从我身边经过 溅我一身呢 我的四十岁 还有十几年 十几年后 我也要开着豪车 回...
    傅少华阅读 191评论 0 0