// This file is autogenerated, DO NOT EDIT
// Use `node scripts/generate-docs-examples.js` to generate the docs examples

[source, js]
----
const response = await client.reindex({
  body: {
    source: {
      index: 'metricbeat-*'
    },
    dest: {
      index: 'metricbeat'
    },
    script: {
      lang: 'painless',
      source: "ctx._index = 'metricbeat-' + (ctx._index.substring('metricbeat-'.length(), ctx._index.length())) + '-1'"
    }
  }
})
console.log(response)
----

