A, reference

Elasticsearch Learning Series Directory — Update ing

Second, the sample

2.1 Modify the field name

Modify the field name, that is, first delete the original field, assign a new field

POST _reindex
{
  "source": {
    "index": "yztest"
  },
  "dest": {
    "index": "yztest1"
  },
  "script": {
    "lang": "painless", 
    "source": """
      for (item in params.updateFields){
        if (ctx._source.containsKey(item)){
          def newItem = "df_" + item;
          ctx['_source'][newItem] = ctx._source.remove(item);
        }
      }
    """,
    "params": {
      "updateFields": ["f1", "f2"]
    }
  }
}

2.2 the queryreindexTask execution

GET _tasks? actions=*reindex*

{" nodes ": {" 111" : {" name ":" 11111 ", "transport_address" : "127.0.0.1:9300", "the host" : "127.0.0.1", "IP" : "127.0.0.1:9300", "roles" : [" ingest ", "master", "data", "ml"], "attributes" : {" ml. Machine_memory ": "16655953920", "xpack.installed" : "true", "ml.max_open_jobs" : "20" }, "tasks" : { "LrCxElELQGqRNI4tok60ug:225074201" : { "node" : "LrCxElELQGqRNI4tok60ug", "id" : 225074201, "type" : "transport", "action" : "indices:data/write/reindex", "start_time_in_millis" : 1624954354511, "running_time_in_nanos" : 438795513169, "cancellable" : true, "headers" : { } } } } } }