How to do it...

The HTTP method to reindex an index is POST. The URL format to get a mapping is http://<server>/_reindex.

To reindex the data between two indices, we will perform the following steps:

  1. If we want to reindex data from myindex to the myindex2 index, the call will be as follows:
POST /_reindex?pretty=true
{
"source": {
"index": "myindex"
},
"dest": {
"index": "myindex2"
}
}
  1. The result returned by Elasticsearch should be as follows:
{
"took" : 20,
"timed_out" : false,
"total" : 0,
"updated" : 0,
"created" : 0,
"deleted" : 0,
"batches" : 0,
"version_conflicts" : 0,
"noops" : 0,
"retries" : {
"bulk" : 0,
"search" : 0
},
"throttled_millis" : 0,
"requests_per_second" : -1.0,
"throttled_until_millis" : 0,
"failures" : [ ]
}