Skip to content

Instantly share code, notes, and snippets.

@martijnvg
Created December 5, 2012 11:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save martijnvg/4214961 to your computer and use it in GitHub Desktop.
Save martijnvg/4214961 to your computer and use it in GitHub Desktop.
Show all indices.
import org.elasticsearch.action.admin.indices.status.IndicesStatusResponse;
import org.elasticsearch.client.Client;
import org.elasticsearch.common.metrics.CounterMetric;
import org.elasticsearch.index.field.data.FieldData;
import org.elasticsearch.index.field.data.ints.SingleValueIntFieldData;
import org.elasticsearch.node.Node;
import org.elasticsearch.node.NodeBuilder;
/**
*/
public class Testje {
public static void main(String[] args) {
Node node = NodeBuilder.nodeBuilder().node();
node.start();
Client client = node.client();
client.admin().indices().prepareCreate("test1").execute().actionGet();
client.admin().indices().prepareCreate("test2").execute().actionGet();
client.admin().indices().prepareCreate("test3").execute().actionGet();
IndicesStatusResponse response = client.admin().indices().prepareStatus().execute().actionGet();
for (String index : response.indices().keySet()) {
System.out.println(index);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment