【发布时间】:2017-02-24 04:02:07
【问题描述】:
我有这个映射的索引:
curl -XPUT 'http://localhost:9200/origindex/_mapping/page' -d '
{
"page" : {
"properties" : {
"title" : {"type" : "text"},
"body" : {"type" : "text"},
"other": {"type": "text"}
}
}
}'
在新索引中,我想将“title”复制到“title1”和“title2”,将“body”复制到“body1”和“body2”(忽略“other”),并将类型从“page ”到“articles_eng”。新索引有这个映射:
curl -XPUT 'http://localhost:9200/newindex/_mapping/articles_eng' -d '
{
"articles_eng" : {
"properties" : {
"title1" : {
"type" : "text",
"analyzer" : "my_analyzer1"
},
"title2" : {
"type" : "text",
"analyzer": "my_analyzer2"
},
"body1": {
"type" : "text",
"analyzer": "my_analyzer1"
},
"body2" : {
"type" : "text",
"analyzer": "my_analyzer2"
}
}
}
}'
通过查看this answer 和Elasticsearch reindex docs 我想出了这样的事情:
curl -XPOST http://localhost:9200/_reindex -d '{
"source": {
"index": "origindex",
"type": "page",
"query": {
"match_all": {}
},
"_source": [ "title", "body" ]
},
"dest": {
"index": "newindex"
},
"script": {
"inline": "ctx._type = \"articles_eng\"";
"ctx._title1 = ctx._source._title";
"ctx._title2 = ctx._source._title";
"ctx._body1 = ctx._source._body";
"ctx._body2 = ctx._source._body"
}
}'
脚本行有问题。如果我只做第一行(更改文档类型),一切正常。如果我添加其余的行,我会收到错误
“[reindex] 解析字段 [script] 失败”
由
引起“意外字符(';'(代码 59)):期待逗号分隔 [Source: 中的对象条目\n org.elasticsearch.transport.netty4.ByteBufStreamInput@37649463;线: 14、栏目:50]"
即使我可以通过多条语句解决问题,但只输入第二行就会出现错误
“添加到上下文 [title1] 的无效字段”}]
谁能帮帮我?看来这应该不是不可能的事。
【问题讨论】:
标签: elasticsearch