Deprecated index status classes in ES 1.2


(Brian Yoder) #1

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


(Brian Yoder) #2

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


(system) #3