title: how to rename an index in a cluster?
body: <p>I need to rename several indexes in a cluster (their name <strong>must</strong> be changed, I cannot use <a href="http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/indices-aliases.html">aliases</a>).</p>
  
  <p>I saw that there are no supported ways to do that, the closest I found is to <a href="https://gist.github.com/nz/6322673">rename the directory of the index</a>, I tried this in a cluster.</p>
  
  <p>The cluster has 3 machines <code>A</code>, <code>B</code> and <code>C</code> and the shards are replicated on each of them. I shut down elasticsearch on <code>A</code>, renamed <code>/var/lib/elasticsearch/security/nodes/0/indices/oldindexname</code> to <code>/var/lib/elasticsearch/security/nodes/0/indices/newindexname</code> and restarted <code>A</code>.</p>
  
  <p>The state of the cluster was yellow and elasticsearch was doing some magic to restore a correct state. After some time I ended up with</p>
  
  <ul>
  <li><code>oldindexname</code> being available and fully replicated (recovered from <code>B</code> and <code>C</code> I guess) </li>
  <li><code>newindexname</code> being available (I can search it) but the head plugin shows that its shards are in an "Unassigned" state and that they are grayed out (not replicated)</li>
  </ul>
  
  <p>During the recovery <code>security.log</code> showed the following message:</p>
  
  <pre><code>[2015-02-20 11:02:33,461][INFO ][gateway.local.state.meta ] [A.example.com] dangled index directory name is [newindexname], state name is [oldindexname], renaming to directory name
  </code></pre>
  
  <p>While <code>newindexname</code> is searchable, it is certainly not in a normal state.</p>
  
  <p>I rolled back to the previous state by deleting <code>newindexname</code>. The cluster is back to green without any "Unassigned" entries.</p>
  
  <p>Given that, how can I rename <code>oldindexname</code> to <code>newindexname</code> in a cluster?</p>
  
  <p><strong>Note:</strong> the ultimate solution I have in mind is to scroll-copy <code>oldindex</code> into <code>newindex</code> and delete <code>oldindex</code> afterwards. This is going to take time so if there is a more direct solution it would be great.</p>