# Rename an index

**URL:** <https://discuss.elastic.co/t/rename-an-index/9491>\
**Category:** Elasticsearch\
**Created:** [October 29, 2012, 11:12am UTC](https://discuss.elastic.co/t/rename-an-index/9491 "2012-10-29T11:12:53Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tarek\_Ziade](https://avatars.discourse-cdn.com/v4/letter/t/34f0e0/32.png) [@Tarek\_Ziade](https://discuss.elastic.co/u/Tarek_Ziade)\
**Post date:** [October 29, 2012, 11:12am UTC](https://discuss.elastic.co/t/rename-an-index/9491/1 "2012-10-29T11:12:53Z")

</div>

Hey

Is there a way to rename (or copy) an index from the APIs ? -- not an  
alias.

Thanks  
Tarek

--

---

<div class="post-metadata">

**Author:** ![Benoit](https://avatars.discourse-cdn.com/v4/letter/b/5daacb/32.png) [@Benoit](https://discuss.elastic.co/u/Benoit)\
**Post date:** [October 29, 2012, 3:48pm UTC](https://discuss.elastic.co/t/rename-an-index/9491/2 "2012-10-29T15:48:47Z")

</div>

To my knowledge, there is no "rename" or "copy" API.

For copy, you can search for scroll and scan API to iterate over all docs  
and index them in a new index.

Benoît

On Monday, October 29, 2012 12:12:53 PM UTC+1, Tarek Ziadé wrote:

> Hey
> 
> Is there a way to rename (or copy) an index from the APIs ? -- not an  
> alias.
> 
> Thanks  
> Tarek

--

---

<div class="post-metadata">

**Author:** ![vineeth\_mohan](https://avatars.discourse-cdn.com/v4/letter/v/bc79bd/32.png) [@vineeth\_mohan](https://discuss.elastic.co/u/vineeth_mohan)\
**Post date:** [October 30, 2012, 2:56am UTC](https://discuss.elastic.co/t/rename-an-index/9491/3 "2012-10-30T02:56:19Z")

</div>

A better option would be to maintain aliases -

> **[Elasticsearch Platform — Find real-time answers at scale](https://www.elastic.co)**
>
> Power insights and outcomes with the Elasticsearch Platform and AI. See into your data and find answers that matter with enterprise solutions designed to help you build, observe, and protect. Try Elasticsearch free today.

Thanks  
Vineeth

On Mon, Oct 29, 2012 at 9:18 PM, Benoît [benoit.intrw@gmail.com](mailto:benoit.intrw@gmail.com) wrote:

> To my knowledge, there is no "rename" or "copy" API.
> 
> For copy, you can search for scroll and scan API to iterate over all docs  
> and index them in a new index.
> 
> Benoît
> 
> On Monday, October 29, 2012 12:12:53 PM UTC+1, Tarek Ziadé wrote:
> 
> > Hey
> > 
> > Is there a way to rename (or copy) an index from the APIs ? -- not an  
> > alias.
> > 
> > Thanks  
> > Tarek
> 
> --

--

---

<div class="post-metadata">

**Author:** ![Tarek\_Ziade](https://avatars.discourse-cdn.com/v4/letter/t/34f0e0/32.png) [@Tarek\_Ziade](https://discuss.elastic.co/u/Tarek_Ziade)\
**Post date:** [October 30, 2012, 9:04am UTC](https://discuss.elastic.co/t/rename-an-index/9491/4 "2012-10-30T09:04:37Z")

</div>

On Monday, October 29, 2012 4:48:47 PM UTC+1, Benoît wrote:

> To my knowledge, there is no "rename" or "copy" API.
> 
> For copy, you can search for scroll and scan API to iterate over all docs  
> and index them in a new index.

Yeah I will try that. It sounds suboptimal though, maybe I should post a  
feature request.

Thanks

--

---

<div class="post-metadata">

**Author:** ![Tarek\_Ziade](https://avatars.discourse-cdn.com/v4/letter/t/34f0e0/32.png) [@Tarek\_Ziade](https://discuss.elastic.co/u/Tarek_Ziade)\
**Post date:** [October 30, 2012, 9:06am UTC](https://discuss.elastic.co/t/rename-an-index/9491/5 "2012-10-30T09:06:36Z")

</div>

On Tuesday, October 30, 2012 3:56:23 AM UTC+1, Vineeth Mohan wrote:

> A better option would be to maintain aliases -  
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/api/admin-indices-aliases.html)
> 
> Thanks  
> Vineeth

That's what we do now - but I have an existing instance with some indexes I  
wanted to copy over.

> On Mon, Oct 29, 2012 at 9:18 PM, Benoît \<[benoit...@gmail.com](mailto:benoit...@gmail.com) \<javascript:\>
> 
> > wrote:
> 
> > To my knowledge, there is no "rename" or "copy" API.
> > 
> > For copy, you can search for scroll and scan API to iterate over all docs  
> > and index them in a new index.
> > 
> > Benoît
> > 
> > On Monday, October 29, 2012 12:12:53 PM UTC+1, Tarek Ziadé wrote:
> > 
> > > Hey
> > > 
> > > Is there a way to rename (or copy) an index from the APIs ? -- not an  
> > > alias.
> > > 
> > > Thanks  
> > > Tarek
> > 
> > --

--

---

<div class="post-metadata">

**Author:** ![Clinton\_Gormley](https://avatars.discourse-cdn.com/v4/letter/c/50afbb/32.png) [@Clinton\_Gormley](https://discuss.elastic.co/u/Clinton_Gormley)\
**Post date:** [October 30, 2012, 9:14am UTC](https://discuss.elastic.co/t/rename-an-index/9491/6 "2012-10-30T09:14:00Z")

</div>

On Tue, 2012-10-30 at 02:06 -0700, Tarek Ziadé wrote:

> On Tuesday, October 30, 2012 3:56:23 AM UTC+1, Vineeth Mohan wrote:  
> A better option would be to maintain aliases -  
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/api/admin-indices-aliases.html)
> 
> ```
> Thanks
> Vineeth
> 
> ```
> 
> That's what we do now - but I have an existing instance with some  
> indexes I wanted to copy over.

Ah, you can import dangling indices into a cluster. The problem is when  
they have the same name as existing indices.

I opened this issue about exactly that problem:

> <https://github.com/elastic/elasticsearch/issues/2314>
>
> If I copy the directory that contains an index to a new directory name, then res…tart the cluster, I see the message:
> 
> \`\`\`
> \[INFO \]\[gateway.local.state.meta \] \[Sytsevich, Aleksei\] dangled index directory name is \[new\_name\], state name is \[old\_name\], renaming to directory name
> \`\`\`
> 
> This, to me, implies that the state name is being changed to the directory name. In other words, I should have a new index called \`new\_name\`.
> 
> Actually, it just ignores the index because we already have \`old\_name\`.
> 
> If I edit the state file to change the state name, then I get a new index with the edited name.
> 
> So first: the log message is inaccurate. It should be "renaming to state name".
> But second, I think the better behaviour would be to update the state name to the directory name. For one, this would make it easy to physically rename an index.

clint

> 

--

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 6, 2017, 3:06am UTC](https://discuss.elastic.co/t/rename-an-index/9491/7 "2017-07-06T03:06:50Z")

</div>


