# Deprecated index status classes in ES 1.2

**URL:** <https://discuss.elastic.co/t/deprecated-index-status-classes-in-es-1-2/17761>\
**Category:** Elasticsearch\
**Created:** [May 27, 2014, 7:21pm UTC](https://discuss.elastic.co/t/deprecated-index-status-classes-in-es-1-2/17761 "2014-05-27T19:21:50Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![brian\_yoder](https://avatars.discourse-cdn.com/v4/letter/b/f1d935/32.png) [@brian\_yoder](https://discuss.elastic.co/u/brian_yoder)\
**Post date:** [May 27, 2014, 7:21pm UTC](https://discuss.elastic.co/t/deprecated-index-status-classes-in-es-1-2/17761/1 "2014-05-27T19:21:50Z")

</div>

Up through ES 1.1.1 the following Java snippet was able to take an array of  
one or more index specifications (e.g. test\*, ix\*, sgen) and create a list  
of index names that match (e.g. test1, test2, test3, ix1, ix2, sgen):

/\* Create array of 1 or more index specifications \*/  
String[] indexSpecList = parseIndex(indexPattern);

/\*

- Get the list of individual index names, along with their status
- information (which we will ignore in this method)  
\*/  
IndicesAdminClient iac = client.admin().indices();  
IndicesStatusRequestBuilder isrb = iac.prepareStatus();  
isrb.setIndices(indexSpecList);  
IndicesStatusResponse isr = isrb.execute().actionGet();

/\* Create an array of just the names of the indices \*/  
ArrayList indices = new ArrayList();  
Map\<String, IndexStatus\> ismap = isr.getIndices();  
for (String index : ismap.keySet())  
{  
indices.add(index);  
}

But in ES 1.2, the following classes are deprecated (and therefore result  
in Javac build warnings which mean that someday these APIs may vanish).

import org.elasticsearch.action.admin.indices.status.IndexStatus;  
import org.elasticsearch.action.admin.indices.status.  
IndicesStatusRequestBuilder;  
import org.elasticsearch.action.admin.indices.status.IndicesStatusResponse;

What is the new recommendation for getting a list of the index names that  
match a pattern? Would someone kindly point me to the acceptable 1.2  
version of the API methods? Thank you!

Brian

--  
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).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/68b00e23-7167-49f4-8738-a2ec2d8847f9%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/68b00e23-7167-49f4-8738-a2ec2d8847f9%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![brian\_yoder](https://avatars.discourse-cdn.com/v4/letter/b/f1d935/32.png) [@brian\_yoder](https://discuss.elastic.co/u/brian_yoder)\
**Post date:** [May 27, 2014, 8:47pm UTC](https://discuss.elastic.co/t/deprecated-index-status-classes-in-es-1-2/17761/2 "2014-05-27T20:47:25Z")

</div>

Finally figured out the answer to my own question! Digging through the  
deprecated REST API documentation and stumbling across  
[https://github.com/elasticsearch/elasticsearch/pull/5094/files](https://github.com/elasticsearch/elasticsearch/pull/5094/files) I found  
enough to be able to convert my code to use the new recovery-based API and  
no longer use the deprecated API. As promised, the code changes were  
minimal. Testing showed that the list of index names is identical using  
either the deprecated API (my previous code) or the new recovery API (my  
updates below, with changes in _bold_). Hope this helps someone else who is  
migrating their Java code:

/\* Create array of 1 or more index specifications \*/  
String[] indexSpecList = parseIndex(indexPattern);

/\*

- Get the list of individual index names, along with their status
- information (which we will ignore in this method)  
\*/  
IndicesAdminClient iac = client.admin().indices();  
_RecoveryRequestBuilder_ isrb = iac._prepareRecoveries_();  
isrb.setIndices(indexSpecList);  
_RecoveryResponse_ isr = isrb.execute().actionGet();

/\* Create an array of just the names of the indices \*/  
ArrayList indices = new ArrayList();  
_Map\<String, List\> sr = isr.shardResponses()_;  
for (String index : _sr_.keySet())  
{  
indices.add();  
}

And the Javac build has no more warnings about deprecated methods. Yay!

Brian

--  
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).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/7bb70006-baef-45d0-9261-2a0b145706af%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/7bb70006-baef-45d0-9261-2a0b145706af%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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, 1:26am UTC](https://discuss.elastic.co/t/deprecated-index-status-classes-in-es-1-2/17761/3 "2017-07-06T01:26:33Z")

</div>


