elasticsearch reindex change document structure

Viewed 144

I plan on using the _reindex api to reindex some data. Is there a way in which you can flatten an array during the operation using a script and reindex this array as individual documents?

Note: I know I can use scan and scroll, but was hoping to use the in-build reindex API, as it gives a nice progress indication via the tasks api.

I have a structure like the following in index_a

{
 "field_a": [
   "value_a", 
   "value_b"
  ]
}

What I would like to do during the reindex is to create individual documents for each of the items in the array during the _reindex operation. I would like something that does this:

doc_1:

{
   "field": "value_a"
}

and doc_2:

{
   "field": "value_b"
}

ElasticSearch Version: 2.4

Is this even possible or would I have to use something like a custom plugin to do this?

0 Answers
Related