如果仅执行第一行(更改文档类型),则一切正常。如果我添加其余的行,则会出现错误
您不需要将所有内联语句都放在双引号中,而是可以将所有内联脚本语句都用分号(
;)分隔并用双引号(
")括起来,如下所示:
"script": { "inline": "ctx._source.title1 = ctx._source.title; ctx._source.title2 = ctx._source.remove("title");ctx._source.body1 = ctx._source.body; ctx._source.body2 = ctx._source.remove("body");ctx._type="articles_eng""}即使我可以使用多条语句来解决问题,也只需在第二行中输入错误即可
您试图以错误的方式访问源字段。元数据字段(如
_id, _type, _index ..)应作为
ctx._type/
访问
ctx._id,而源字段(如
title, body, other您的情况)应作为
ctx._source.title/
访问
ctx._source.body。
因此,最后,您的ReIndex查询应如下所示:
POST _reindex{ "source": { "index": "origindex", "_source": [ "title", "body" ] }, "dest": { "index": "newindex" }, "script": { "inline": "ctx._source.title1 = ctx._source.title; ctx._source.title2 = ctx._source.remove("title");ctx._source.body1 = ctx._source.body; ctx._source.body2 = ctx._source.remove("body");ctx._type="articles_eng"" }}希望这可以帮助!



