# Retrieving Index by Alias

**URL:** <https://discuss.elastic.co/t/retrieving-index-by-alias/14241>\
**Category:** Elasticsearch\
**Created:** [November 4, 2013, 12:33pm UTC](https://discuss.elastic.co/t/retrieving-index-by-alias/14241 "2013-11-04T12:33:43Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alexander\_Kley](https://avatars.discourse-cdn.com/v4/letter/a/6a8cbe/32.png) [@Alexander\_Kley](https://discuss.elastic.co/u/Alexander_Kley)\
**Post date:** [November 4, 2013, 12:33pm UTC](https://discuss.elastic.co/t/retrieving-index-by-alias/14241/1 "2013-11-04T12:33:43Z")

</div>

Hi all,

is it possible to retrieve all indexes by their alias? I need the inverted  
way like described in RestGetIndicesAliasesAction.class (Line 59). Such  
give me all indices pointed to given alias.

Best regards  
Alex

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Alexander\_Kley](https://avatars.discourse-cdn.com/v4/letter/a/6a8cbe/32.png) [@Alexander\_Kley](https://discuss.elastic.co/u/Alexander_Kley)\
**Post date:** [November 4, 2013, 12:42pm UTC](https://discuss.elastic.co/t/retrieving-index-by-alias/14241/2 "2013-11-04T12:42:14Z")

</div>

To be more concrete:

I'll be able to rebuild an index "my\_index\_v1" to "my\_index\_v2", pointed  
to the alias "my\_index". The process itself is well known by myself. My  
problem is to calculate the next number for \_v.. in a generic way.  
So my idea was to get the index name, which is pointed to the known alias,  
parse them, get the \_v sufix and create a new index based on the result of  
parsing, adding them to the alias,...... , remove the old index from alias.

Cheers  
Alex

Am Montag, 4. November 2013 13:33:43 UTC+1 schrieb Alexander Kley:

> Hi all,
> 
> is it possible to retrieve all indexes by their alias? I need the inverted  
> way like described in RestGetIndicesAliasesAction.class (Line 59). Such  
> give me all indices pointed to given alias.
> 
> Best regards  
> Alex

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Boaz\_Leskes](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/boaz_leskes/32/723_2.png) [@Boaz\_Leskes](https://discuss.elastic.co/u/Boaz_Leskes)\
**Post date:** [November 4, 2013, 12:45pm UTC](https://discuss.elastic.co/t/retrieving-index-by-alias/14241/3 "2013-11-04T12:45:42Z")

</div>

Hey Alex,

Currently, your only option is to get all the aliases and filter to the one  
you want.

Does sound like a good idea. Please feel free to open an issue on github.

Cheers,  
Boaz

On Monday, November 4, 2013 1:33:43 PM UTC+1, Alexander Kley wrote:

> Hi all,
> 
> is it possible to retrieve all indexes by their alias? I need the inverted  
> way like described in RestGetIndicesAliasesAction.class (Line 59). Such  
> give me all indices pointed to given alias.
> 
> Best regards  
> Alex

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Alexander\_Kley](https://avatars.discourse-cdn.com/v4/letter/a/6a8cbe/32.png) [@Alexander\_Kley](https://discuss.elastic.co/u/Alexander_Kley)\
**Post date:** [November 4, 2013, 12:50pm UTC](https://discuss.elastic.co/t/retrieving-index-by-alias/14241/4 "2013-11-04T12:50:52Z")

</div>

Thanks Boaz,

the problem is not the filtering, more the retrieving of alias "containg  
indices"-data" 😉

Am Montag, 4. November 2013 13:45:42 UTC+1 schrieb Boaz Leskes:

> Hey Alex,
> 
> Currently, your only option is to get all the aliases and filter to the  
> one you want.
> 
> Does sound like a good idea. Please feel free to open an issue on github.
> 
> Cheers,  
> Boaz
> 
> On Monday, November 4, 2013 1:33:43 PM UTC+1, Alexander Kley wrote:
> 
> > Hi all,
> > 
> > is it possible to retrieve all indexes by their alias? I need the  
> > inverted way like described in RestGetIndicesAliasesAction.class (Line  
> > 59). Such give me all indices pointed to given alias.
> > 
> > Best regards  
> > Alex

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Boaz\_Leskes](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/boaz_leskes/32/723_2.png) [@Boaz\_Leskes](https://discuss.elastic.co/u/Boaz_Leskes)\
**Post date:** [November 4, 2013, 1:11pm UTC](https://discuss.elastic.co/t/retrieving-index-by-alias/14241/5 "2013-11-04T13:11:40Z")

</div>

Hi Alex,

Not sure I follow.

If you do curl -XGET "[http://localhost:9200/\_aliases/](http://localhost:9200/_aliases/)" , you get

{  
"index1": {  
"aliases": {  
"alias1": {}  
}  
},  
"index2": {  
"aliases": {  
"alias2": {},  
"alias1": {}  
}  
}  
}

Where you have all the information you need?

Cheers,  
Boaz

On Mon, Nov 4, 2013 at 1:50 PM, Alexander Kley [alexander.kley@gmail.com](mailto:alexander.kley@gmail.com)wrote:

> Thanks Boaz,
> 
> the problem is not the filtering, more the retrieving of alias "containg  
> indices"-data" 😉
> 
> Am Montag, 4. November 2013 13:45:42 UTC+1 schrieb Boaz Leskes:
> 
> > Hey Alex,
> > 
> > Currently, your only option is to get all the aliases and filter to the  
> > one you want.
> > 
> > Does sound like a good idea. Please feel free to open an issue on github.
> > 
> > Cheers,  
> > Boaz
> > 
> > On Monday, November 4, 2013 1:33:43 PM UTC+1, Alexander Kley wrote:
> > 
> > > Hi all,
> > > 
> > > is it possible to retrieve all indexes by their alias? I need the  
> > > inverted way like described in RestGetIndicesAliasesAction.class (Line  
> > > 59). Such give me all indices pointed to given alias.
> > > 
> > > Best regards  
> > > Alex
> > 
> > --  
> > You received this message because you are subscribed to a topic in the  
> > Google Groups "elasticsearch" group.  
> > To unsubscribe from this topic, visit  
> > [https://groups.google.com/d/topic/elasticsearch/UiJDLna89J8/unsubscribe](https://groups.google.com/d/topic/elasticsearch/UiJDLna89J8/unsubscribe).  
> > To unsubscribe from this group and all its topics, send an email to  
> > [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> > For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Alexander\_Kley](https://avatars.discourse-cdn.com/v4/letter/a/6a8cbe/32.png) [@Alexander\_Kley](https://discuss.elastic.co/u/Alexander_Kley)\
**Post date:** [November 4, 2013, 1:48pm UTC](https://discuss.elastic.co/t/retrieving-index-by-alias/14241/6 "2013-11-04T13:48:56Z")

</div>

Ok that's an idea. But i'm using th java api. can you post the java api  
call.

Cheers,  
Alex

Am Montag, 4. November 2013 14:11:40 UTC+1 schrieb Boaz Leskes:

> Hi Alex,
> 
> Not sure I follow.
> 
> If you do curl -XGET "[http://localhost:9200/\_aliases/](http://localhost:9200/_aliases/)" , you get
> 
> {  
> "index1": {  
> "aliases": {  
> "alias1": {}  
> }  
> },  
> "index2": {  
> "aliases": {  
> "alias2": {},  
> "alias1": {}  
> }  
> }  
> }
> 
> Where you have all the information you need?
> 
> Cheers,  
> Boaz
> 
> On Mon, Nov 4, 2013 at 1:50 PM, Alexander Kley \<[alexand...@gmail.com](mailto:alexand...@gmail.com)\<javascript:\>
> 
> > wrote:
> 
> > Thanks Boaz,
> > 
> > the problem is not the filtering, more the retrieving of alias "containg  
> > indices"-data" 😉
> > 
> > Am Montag, 4. November 2013 13:45:42 UTC+1 schrieb Boaz Leskes:
> > 
> > > Hey Alex,
> > > 
> > > Currently, your only option is to get all the aliases and filter to the  
> > > one you want.
> > > 
> > > Does sound like a good idea. Please feel free to open an issue on github.
> > > 
> > > Cheers,  
> > > Boaz
> > > 
> > > On Monday, November 4, 2013 1:33:43 PM UTC+1, Alexander Kley wrote:
> > > 
> > > > Hi all,
> > > > 
> > > > is it possible to retrieve all indexes by their alias? I need the  
> > > > inverted way like described in RestGetIndicesAliasesAction\*\*.class  
> > > > (Line 59). Such give me all indices pointed to given alias.
> > > > 
> > > > Best regards  
> > > > Alex
> > > 
> > > --  
> > > You received this message because you are subscribed to a topic in the  
> > > Google Groups "elasticsearch" group.  
> > > To unsubscribe from this topic, visit  
> > > [https://groups.google.com/d/topic/elasticsearch/UiJDLna89J8/unsubscribe](https://groups.google.com/d/topic/elasticsearch/UiJDLna89J8/unsubscribe).  
> > > To unsubscribe from this group and all its topics, send an email to  
> > > [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com) \<javascript:\>.  
> > > For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Boaz\_Leskes](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/boaz_leskes/32/723_2.png) [@Boaz\_Leskes](https://discuss.elastic.co/u/Boaz_Leskes)\
**Post date:** [November 4, 2013, 2:32pm UTC](https://discuss.elastic.co/t/retrieving-index-by-alias/14241/7 "2013-11-04T14:32:40Z")

</div>

Well, the example is in the same RestGetIndicesAliasesAction you referred  
to. You do a cluster state request:

client.admin().cluster().prepareState().setFilterNodes(true).setFilterRoutingTable(true).get()

The in the response:  
MetaData metaData = response.getState().metaData();  
for (IndexMetaData indexMetaData : metaData) ....

You'd have to look at indexMetaData.aliases().containsKey("alias")

Cheers,  
Boaz

On Mon, Nov 4, 2013 at 2:48 PM, Alexander Kley [alexander.kley@gmail.com](mailto:alexander.kley@gmail.com)wrote:

> Ok that's an idea. But i'm using th java api. can you post the java api  
> call.
> 
> Cheers,  
> Alex
> 
> Am Montag, 4. November 2013 14:11:40 UTC+1 schrieb Boaz Leskes:
> 
> > Hi Alex,
> > 
> > Not sure I follow.
> > 
> > If you do curl -XGET "[http://localhost:9200/\_aliases/](http://localhost:9200/_aliases/)" , you get
> > 
> > {  
> > "index1": {  
> > "aliases": {  
> > "alias1": {}  
> > }  
> > },  
> > "index2": {  
> > "aliases": {  
> > "alias2": {},  
> > "alias1": {}  
> > }  
> > }  
> > }
> > 
> > Where you have all the information you need?
> > 
> > Cheers,  
> > Boaz
> > 
> > On Mon, Nov 4, 2013 at 1:50 PM, Alexander Kley [alexand...@gmail.com](mailto:alexand...@gmail.com)wrote:
> > 
> > > Thanks Boaz,
> > > 
> > > the problem is not the filtering, more the retrieving of alias "containg  
> > > indices"-data" 😉
> > > 
> > > Am Montag, 4. November 2013 13:45:42 UTC+1 schrieb Boaz Leskes:
> > > 
> > > > Hey Alex,
> > > > 
> > > > Currently, your only option is to get all the aliases and filter to the  
> > > > one you want.
> > > > 
> > > > Does sound like a good idea. Please feel free to open an issue on  
> > > > github.
> > > > 
> > > > Cheers,  
> > > > Boaz
> > > > 
> > > > On Monday, November 4, 2013 1:33:43 PM UTC+1, Alexander Kley wrote:
> > > > 
> > > > > Hi all,
> > > > > 
> > > > > is it possible to retrieve all indexes by their alias? I need the  
> > > > > inverted way like described in RestGetIndicesAliasesAction.class  
> > > > > (Line 59). Such give me all indices pointed to given alias.
> > > > > 
> > > > > Best regards  
> > > > > Alex
> > > > 
> > > > --  
> > > > You received this message because you are subscribed to a topic in the  
> > > > Google Groups "elasticsearch" group.  
> > > > To unsubscribe from this topic, visit [https://groups.google.com/d/](https://groups.google.com/d/)  
> > > > topic/elasticsearch/UiJDLna89J8/unsubscribe.  
> > > > To unsubscribe from this group and all its topics, send an email to  
> > > > [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com).
> > > 
> > > For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).
> > 
> > --  
> > You received this message because you are subscribed to a topic in the  
> > Google Groups "elasticsearch" group.  
> > To unsubscribe from this topic, visit  
> > [https://groups.google.com/d/topic/elasticsearch/UiJDLna89J8/unsubscribe](https://groups.google.com/d/topic/elasticsearch/UiJDLna89J8/unsubscribe).  
> > To unsubscribe from this group and all its topics, send an email to  
> > [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> > For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Alexander\_Kley](https://avatars.discourse-cdn.com/v4/letter/a/6a8cbe/32.png) [@Alexander\_Kley](https://discuss.elastic.co/u/Alexander_Kley)\
**Post date:** [November 4, 2013, 3:28pm UTC](https://discuss.elastic.co/t/retrieving-index-by-alias/14241/8 "2013-11-04T15:28:58Z")

</div>

This could fix my problem - thanks! By the way, th key is "aliases".

Cheers,  
Alex

Am Montag, 4. November 2013 15:32:40 UTC+1 schrieb Boaz Leskes:

> Well, the example is in the same RestGetIndicesAliasesAction you referred  
> to. You do a cluster state request:
> 
> client.admin().cluster().prepareState().setFilterNodes(true).setFilterRoutingTable(true).get()
> 
> The in the response:  
> MetaData metaData = response.getState().metaData();  
> for (IndexMetaData indexMetaData : metaData) ....
> 
> You'd have to look at indexMetaData.aliases().containsKey("alias")
> 
> Cheers,  
> Boaz
> 
> On Mon, Nov 4, 2013 at 2:48 PM, Alexander Kley \<[alexand...@gmail.com](mailto:alexand...@gmail.com)\<javascript:\>
> 
> > wrote:
> 
> > Ok that's an idea. But i'm using th java api. can you post the java api  
> > call.
> > 
> > Cheers,  
> > Alex
> > 
> > Am Montag, 4. November 2013 14:11:40 UTC+1 schrieb Boaz Leskes:
> > 
> > > Hi Alex,
> > > 
> > > Not sure I follow.
> > > 
> > > If you do curl -XGET "[http://localhost:9200/\_\*\*aliases/](http://localhost:9200/_**aliases/)[http://localhost:9200/\_aliases/](http://localhost:9200/_aliases/)"  
> > > , you get
> > > 
> > > {  
> > > "index1": {  
> > > "aliases": {  
> > > "alias1": {}  
> > > }  
> > > },  
> > > "index2": {  
> > > "aliases": {  
> > > "alias2": {},  
> > > "alias1": {}  
> > > }  
> > > }  
> > > }
> > > 
> > > Where you have all the information you need?
> > > 
> > > Cheers,  
> > > Boaz
> > > 
> > > On Mon, Nov 4, 2013 at 1:50 PM, Alexander Kley [alexand...@gmail.com](mailto:alexand...@gmail.com)wrote:
> > > 
> > > > Thanks Boaz,
> > > > 
> > > > the problem is not the filtering, more the retrieving of alias  
> > > > "containg indices"-data" 😉
> > > > 
> > > > Am Montag, 4. November 2013 13:45:42 UTC+1 schrieb Boaz Leskes:
> > > > 
> > > > > Hey Alex,
> > > > > 
> > > > > Currently, your only option is to get all the aliases and filter to  
> > > > > the one you want.
> > > > > 
> > > > > Does sound like a good idea. Please feel free to open an issue on  
> > > > > github.
> > > > > 
> > > > > Cheers,  
> > > > > Boaz
> > > > > 
> > > > > On Monday, November 4, 2013 1:33:43 PM UTC+1, Alexander Kley wrote:
> > > > > 
> > > > > > Hi all,
> > > > > > 
> > > > > > is it possible to retrieve all indexes by their alias? I need the  
> > > > > > inverted way like described in RestGetIndicesAliasesAction\*\*\*\*.class  
> > > > > > (Line 59). Such give me all indices pointed to given alias.
> > > > > > 
> > > > > > Best regards  
> > > > > > Alex
> > > > > 
> > > > > --  
> > > > > You received this message because you are subscribed to a topic in the  
> > > > > Google Groups "elasticsearch" group.  
> > > > > To unsubscribe from this topic, visit [https://groups.google.com/d/](https://groups.google.com/d/)\*\*  
> > > > > topic/elasticsearch/\*\*UiJDLna89J8/unsubscribe[https://groups.google.com/d/topic/elasticsearch/UiJDLna89J8/unsubscribe](https://groups.google.com/d/topic/elasticsearch/UiJDLna89J8/unsubscribe)  
> > > > > .  
> > > > > To unsubscribe from this group and all its topics, send an email to  
> > > > > elasticsearc...@\*\*[googlegroups.com](http://googlegroups.com).
> > > > 
> > > > For more options, visit [https://groups.google.com/\*\*groups/opt\_out](https://groups.google.com/**groups/opt_out)[https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out)  
> > > > .
> > > 
> > > --  
> > > You received this message because you are subscribed to a topic in the  
> > > Google Groups "elasticsearch" group.  
> > > To unsubscribe from this topic, visit  
> > > [https://groups.google.com/d/topic/elasticsearch/UiJDLna89J8/unsubscribe](https://groups.google.com/d/topic/elasticsearch/UiJDLna89J8/unsubscribe).  
> > > To unsubscribe from this group and all its topics, send an email to  
> > > [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com) \<javascript:\>.  
> > > For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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, 2:09am UTC](https://discuss.elastic.co/t/retrieving-index-by-alias/14241/9 "2017-07-06T02:09:01Z")

</div>


