# Creating an index and alias in the same request

**URL:** https://discuss.elastic.co/t/creating-an-index-and-alias-in-the-same-request/6670
**Category:** Elasticsearch
**Created:** [February 10, 2012, 12:54pm UTC](https://discuss.elastic.co/t/creating-an-index-and-alias-in-the-same-request/6670 "2012-02-10T12:54:48Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)
#### Post date: [February 10, 2012, 12:54pm UTC](https://discuss.elastic.co/t/creating-an-index-and-alias-in-the-same-request/6670/1 "2012-02-10T12:54:48Z")

</div>

Hi,

Is there anyway to create an index and set an alias name on it with only  
one request ?  
Something like :  
curl -XPUT [http://localhost:9200/twitter/](http://localhost:9200/twitter/) -d '

{  
"settings": {  
"number\_of\_shards": 3,  
"number\_of\_replicas": 2  
},  
"alias": [  
"myalias"  
]  
}

'

Thanks,  
David.

--  
David Pilato  
[http://dev.david.pilato.fr/](http://dev.david.pilato.fr/)  
Twitter : @dadoonet

---

<div class="post-metadata">

### Author: ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)
#### Post date: [February 12, 2012, 1:34pm UTC](https://discuss.elastic.co/t/creating-an-index-and-alias-in-the-same-request/6670/2 "2012-02-12T13:34:49Z")

</div>

No, there ins't an option to do so (at least not for a complex alias, with routing and other parameters). You can open an issue...

On Friday, February 10, 2012 at 2:54 PM, [david@pilato.fr](mailto:david@pilato.fr) wrote:

> Hi,
> 
> Is there anyway to create an index and set an alias name on it with only one request ?
> 
> Something like :
> 
> curl -XPUT [http://localhost:9200/twitter/](http://localhost:9200/twitter/) -d '
> 
> {  
> "settings": {  
> "number\_of\_shards": 3,  
> "number\_of\_replicas": 2  
> },  
> "alias": [  
> "myalias"  
> ]  
> }  
> '
> 
> Thanks,
> 
> David.
> 
> --  
> David Pilato  
> [http://dev.david.pilato.fr/](http://dev.david.pilato.fr/)  
> Twitter : @dadoonet

---

<div class="post-metadata">

### Author: ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)
#### Post date: [February 12, 2012, 1:59pm UTC](https://discuss.elastic.co/t/creating-an-index-and-alias-in-the-same-request/6670/3 "2012-02-12T13:59:47Z")

</div>

Ok thanks. Issue opened here : [https://github.com/elasticsearch/elasticsearch/issues/1695](https://github.com/elasticsearch/elasticsearch/issues/1695)

I would be pleased to try to implement it. Could you give an advice on some classes I should look at to start ?

Thanks,  
David.

De : [elasticsearch@googlegroups.com](mailto:elasticsearch@googlegroups.com) [[mailto:elasticsearch@googlegroups.com](mailto:elasticsearch@googlegroups.com)] De la part de Shay Banon  
Envoyé : dimanche 12 février 2012 14:35  
À : [elasticsearch@googlegroups.com](mailto:elasticsearch@googlegroups.com)  
Objet : Re: Creating an index and alias in the same request

No, there ins't an option to do so (at least not for a complex alias, with routing and other parameters). You can open an issue...

On Friday, February 10, 2012 at 2:54 PM, david@pilato.fr wrote:

Hi,

Is there anyway to create an index and set an alias name on it with only one request ?

Something like :

curl -XPUT [http://localhost:9200/twitter/](http://localhost:9200/twitter/) -d '

{  
"settings": {  
"number\_of\_shards": 3,  
"number\_of\_replicas": 2  
},  
"alias": [  
"myalias"  
]  
}

'

Thanks,

David.

--  
David Pilato  
[http://dev.david.pilato.fr/](http://dev.david.pilato.fr/)  
Twitter : @dadoonet

---

<div class="post-metadata">

### Author: ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)
#### Post date: [February 12, 2012, 4:52pm UTC](https://discuss.elastic.co/t/creating-an-index-and-alias-in-the-same-request/6670/4 "2012-02-12T16:52:47Z")

</div>

Lets talk it over on the issue.

On Sunday, February 12, 2012 at 3:59 PM, David Pilato wrote:

> Ok thanks. Issue opened here : [Creating an index and alias in the same request · Issue #1695 · elastic/elasticsearch · GitHub](https://github.com/elasticsearch/elasticsearch/issues/1695)
> 
> I would be pleased to try to implement it. Could you give an advice on some classes I should look at to start ?
> 
> Thanks,  
> David.
> 
> De : [elasticsearch@googlegroups.com](mailto:elasticsearch@googlegroups.com) [[mailto:elasticsearch@googlegroups.com](mailto:elasticsearch@googlegroups.com)] De la part de Shay Banon  
> Envoyé : dimanche 12 février 2012 14:35  
> À : [elasticsearch@googlegroups.com](mailto:elasticsearch@googlegroups.com) ([mailto:elasticsearch@googlegroups.com](mailto:elasticsearch@googlegroups.com))  
> Objet : Re: Creating an index and alias in the same request
> 
> No, there ins't an option to do so (at least not for a complex alias, with routing and other parameters). You can open an issue...
> 
> On Friday, February 10, 2012 at 2:54 PM, [david@pilato.fr](mailto:david@pilato.fr) ([mailto:david@pilato.fr](mailto:david@pilato.fr)) wrote:
> 
> > Hi,
> > 
> > Is there anyway to create an index and set an alias name on it with only one request ?
> > 
> > Something like :
> > 
> > curl -XPUT [http://localhost:9200/twitter/](http://localhost:9200/twitter/) -d '
> > 
> > {  
> > "settings": {  
> > "number\_of\_shards": 3,  
> > "number\_of\_replicas": 2  
> > },  
> > "alias": [  
> > "myalias"  
> > ]  
> > }  
> > '
> > 
> > Thanks,
> > 
> > David.
> > 
> > --  
> > David Pilato  
> > [http://dev.david.pilato.fr/](http://dev.david.pilato.fr/)  
> > Twitter : @dadoonet

---

<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:39am UTC](https://discuss.elastic.co/t/creating-an-index-and-alias-in-the-same-request/6670/5 "2017-07-06T03:39:43Z")

</div>


