title: elasticsearch reindex doesnt use index name specified in script
body: <p>I tried reindexing daily indices from remote cluster and following <a href="https://www.elastic.co/guide/en/elasticsearch/reference/7.17/docs-reindex.html#docs-reindex-daily-indices" rel="nofollow noreferrer">reindex-daily-indices</a> example</p>
  <pre><code>POST _reindex
  {
    &quot;source&quot;: {
      &quot;remote&quot;: {
        &quot;host&quot;: &quot;http://remote_es:9200&quot;
      }, 
      &quot;index&quot;: &quot;telemetry-*&quot;
    },
    &quot;dest&quot;: {
      &quot;index&quot;: &quot;dummy&quot;
    },
    &quot;script&quot;: {
      &quot;lang&quot;: &quot;painless&quot;, 
      &quot;source&quot;: &quot;&quot;&quot;
        ctx._index = 'telemetry-' + (ctx._index.substring('telemetry-'.length(), ctx._index.length()));
      &quot;&quot;&quot;
    }
  }
  </code></pre>
  <p>It looks like if the new <code>ctx._index</code> is exactly the same as the original <code>ctx._index</code>, it will use the <code>dest.index</code> instead. It reindex all the records into &quot;dummy&quot; index</p>
  <ol>
  <li>Is this a bug or intended behaviour? I could not find any explanation to this behaviour.</li>
  <li>Is there a way to reindex (multiple indices) from remote and still preserve the original name?</li>
  </ol>