美文网首页
elasticsearch rename existing fi

elasticsearch rename existing fi

作者: yangyangrenren | 来源:发表于2018-12-25 16:24 被阅读0次

    来自于 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
        }
      ]
    }
    

    相关文章

      网友评论

          本文标题:elasticsearch rename existing fi

          本文链接:https://www.haomeiwen.com/subject/hmeflqtx.html