POST _reindex
{
"source": { "index": "twitter" }, "dest": { "index": "new_twitter" } }
把flag重命名爲taghtml
POST _reindex
{
"source": { "index": "test" }, "dest": { "index": "test2" }, "script": { "inline": "ctx._source.tag = ctx._source.remove(\"flag\")" } }
在數據錄入時,字段yxdm和字段jwzydm數據位置錯位了,如今須要將數據調換回來curl
curl -XPOST 'http://10.130.20.6:8200/_reindex' -d '{ "source": { "index": "sugon_course_students_onduty_2017_05" }, "dest": { "index": "sugon_course_students_onduty_bak2017_05" } }'
注意須要使用yxdm1做爲中間變量存儲交換的字段elasticsearch
curl -XPOST 'http://10.130.20.6:8200/_reindex' -d '{ "source": { "index": "sugon_course_students_onduty_bak2017_05" }, "dest": { "index": "sugon_course_students_onduty_2017_05" }, "script": { "inline": "ctx._source.yxdm1 = ctx._source.remove(\"jwzydm\");ctx._source.jwzydm = ctx._source.remove(\"yxdm\");ctx._source.yxdm = ctx._source.remove(\"yxdm1\")" } }'
https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-reindex.html http://stackoverflow.com/questions/40607350/renaming-fields-in-elasticsearchide