Hello,
I am trying to reindex a large index into a smaller one by filtering . However I would like to retain some of the metadata with a different field name then used in the original index. "_source" allows me to copy over fields as it is. How can have some of the fields renamed while reindexing?
POST _reindex
{
"source": {
"index": ["logstash-2016.09.11","logstash-2016.09.12"],
"_source": ["_type","timestamp","machid"],
"query": {
"term": {
"_type": "DCA_OBC"
}
}
},
"dest": {
"index": "docs_a"
},
"script": {
"inline": "ctx._source.gid = doc[_id]",
"lang": "painless"
}
}
Can I use the painless script in similar form as shown above, to achieve the same? Here gid is the new field name to store the _id of previous index. I want to give this document a new id on reindexing and save the previous one as gid too.
Thanks