use of org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse in project elasticsearch by elastic.
the class SimpleGetMappingsIT method testSimpleGetMappings.
public void testSimpleGetMappings() throws Exception {
client().admin().indices().prepareCreate("indexa").addMapping("typeA", getMappingForType("typeA")).addMapping("typeB", getMappingForType("typeB")).addMapping("Atype", getMappingForType("Atype")).addMapping("Btype", getMappingForType("Btype")).execute().actionGet();
client().admin().indices().prepareCreate("indexb").addMapping("typeA", getMappingForType("typeA")).addMapping("typeB", getMappingForType("typeB")).addMapping("Atype", getMappingForType("Atype")).addMapping("Btype", getMappingForType("Btype")).execute().actionGet();
ClusterHealthResponse clusterHealth = client().admin().cluster().prepareHealth().setWaitForEvents(Priority.LANGUID).setWaitForGreenStatus().execute().actionGet();
assertThat(clusterHealth.isTimedOut(), equalTo(false));
// Get all mappings
GetMappingsResponse response = client().admin().indices().prepareGetMappings().execute().actionGet();
assertThat(response.mappings().size(), equalTo(2));
assertThat(response.mappings().get("indexa").size(), equalTo(4));
assertThat(response.mappings().get("indexa").get("typeA"), notNullValue());
assertThat(response.mappings().get("indexa").get("typeB"), notNullValue());
assertThat(response.mappings().get("indexa").get("Atype"), notNullValue());
assertThat(response.mappings().get("indexa").get("Btype"), notNullValue());
assertThat(response.mappings().get("indexb").size(), equalTo(4));
assertThat(response.mappings().get("indexb").get("typeA"), notNullValue());
assertThat(response.mappings().get("indexb").get("typeB"), notNullValue());
assertThat(response.mappings().get("indexb").get("Atype"), notNullValue());
assertThat(response.mappings().get("indexb").get("Btype"), notNullValue());
// Get all mappings, via wildcard support
response = client().admin().indices().prepareGetMappings("*").setTypes("*").execute().actionGet();
assertThat(response.mappings().size(), equalTo(2));
assertThat(response.mappings().get("indexa").size(), equalTo(4));
assertThat(response.mappings().get("indexa").get("typeA"), notNullValue());
assertThat(response.mappings().get("indexa").get("typeB"), notNullValue());
assertThat(response.mappings().get("indexa").get("Atype"), notNullValue());
assertThat(response.mappings().get("indexa").get("Btype"), notNullValue());
assertThat(response.mappings().get("indexb").size(), equalTo(4));
assertThat(response.mappings().get("indexb").get("typeA"), notNullValue());
assertThat(response.mappings().get("indexb").get("typeB"), notNullValue());
assertThat(response.mappings().get("indexb").get("Atype"), notNullValue());
assertThat(response.mappings().get("indexb").get("Btype"), notNullValue());
// Get all typeA mappings in all indices
response = client().admin().indices().prepareGetMappings("*").setTypes("typeA").execute().actionGet();
assertThat(response.mappings().size(), equalTo(2));
assertThat(response.mappings().get("indexa").size(), equalTo(1));
assertThat(response.mappings().get("indexa").get("typeA"), notNullValue());
assertThat(response.mappings().get("indexb").size(), equalTo(1));
assertThat(response.mappings().get("indexb").get("typeA"), notNullValue());
// Get all mappings in indexa
response = client().admin().indices().prepareGetMappings("indexa").execute().actionGet();
assertThat(response.mappings().size(), equalTo(1));
assertThat(response.mappings().get("indexa").size(), equalTo(4));
assertThat(response.mappings().get("indexa").get("typeA"), notNullValue());
assertThat(response.mappings().get("indexa").get("typeB"), notNullValue());
assertThat(response.mappings().get("indexa").get("Atype"), notNullValue());
assertThat(response.mappings().get("indexa").get("Btype"), notNullValue());
// Get all mappings beginning with A* in indexa
response = client().admin().indices().prepareGetMappings("indexa").setTypes("A*").execute().actionGet();
assertThat(response.mappings().size(), equalTo(1));
assertThat(response.mappings().get("indexa").size(), equalTo(1));
assertThat(response.mappings().get("indexa").get("Atype"), notNullValue());
// Get all mappings beginning with B* in all indices
response = client().admin().indices().prepareGetMappings().setTypes("B*").execute().actionGet();
assertThat(response.mappings().size(), equalTo(2));
assertThat(response.mappings().get("indexa").size(), equalTo(1));
assertThat(response.mappings().get("indexa").get("Btype"), notNullValue());
assertThat(response.mappings().get("indexb").size(), equalTo(1));
assertThat(response.mappings().get("indexb").get("Btype"), notNullValue());
// Get all mappings beginning with B* and A* in all indices
response = client().admin().indices().prepareGetMappings().setTypes("B*", "A*").execute().actionGet();
assertThat(response.mappings().size(), equalTo(2));
assertThat(response.mappings().get("indexa").size(), equalTo(2));
assertThat(response.mappings().get("indexa").get("Atype"), notNullValue());
assertThat(response.mappings().get("indexa").get("Btype"), notNullValue());
assertThat(response.mappings().get("indexb").size(), equalTo(2));
assertThat(response.mappings().get("indexb").get("Atype"), notNullValue());
assertThat(response.mappings().get("indexb").get("Btype"), notNullValue());
}
use of org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse in project elasticsearch by elastic.
the class OpenCloseIndexIT method testCloseOpenMultipleIndices.
public void testCloseOpenMultipleIndices() {
Client client = client();
createIndex("test1", "test2", "test3");
ClusterHealthResponse healthResponse = client.admin().cluster().prepareHealth().setWaitForGreenStatus().execute().actionGet();
assertThat(healthResponse.isTimedOut(), equalTo(false));
CloseIndexResponse closeIndexResponse1 = client.admin().indices().prepareClose("test1").execute().actionGet();
assertThat(closeIndexResponse1.isAcknowledged(), equalTo(true));
CloseIndexResponse closeIndexResponse2 = client.admin().indices().prepareClose("test2").execute().actionGet();
assertThat(closeIndexResponse2.isAcknowledged(), equalTo(true));
assertIndexIsClosed("test1", "test2");
assertIndexIsOpened("test3");
OpenIndexResponse openIndexResponse1 = client.admin().indices().prepareOpen("test1").execute().actionGet();
assertThat(openIndexResponse1.isAcknowledged(), equalTo(true));
OpenIndexResponse openIndexResponse2 = client.admin().indices().prepareOpen("test2").execute().actionGet();
assertThat(openIndexResponse2.isAcknowledged(), equalTo(true));
assertIndexIsOpened("test1", "test2", "test3");
}
use of org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse in project elasticsearch by elastic.
the class OpenCloseIndexIT method testCloseOpenAliasMultipleIndices.
public void testCloseOpenAliasMultipleIndices() {
Client client = client();
createIndex("test1", "test2");
ClusterHealthResponse healthResponse = client.admin().cluster().prepareHealth().setWaitForGreenStatus().execute().actionGet();
assertThat(healthResponse.isTimedOut(), equalTo(false));
IndicesAliasesResponse aliasesResponse1 = client.admin().indices().prepareAliases().addAlias("test1", "test-alias").execute().actionGet();
assertThat(aliasesResponse1.isAcknowledged(), equalTo(true));
IndicesAliasesResponse aliasesResponse2 = client.admin().indices().prepareAliases().addAlias("test2", "test-alias").execute().actionGet();
assertThat(aliasesResponse2.isAcknowledged(), equalTo(true));
CloseIndexResponse closeIndexResponse = client.admin().indices().prepareClose("test-alias").execute().actionGet();
assertThat(closeIndexResponse.isAcknowledged(), equalTo(true));
assertIndexIsClosed("test1", "test2");
OpenIndexResponse openIndexResponse = client.admin().indices().prepareOpen("test-alias").execute().actionGet();
assertThat(openIndexResponse.isAcknowledged(), equalTo(true));
assertIndexIsOpened("test1", "test2");
}
use of org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse in project elasticsearch by elastic.
the class OpenCloseIndexIT method testSimpleCloseOpenAlias.
public void testSimpleCloseOpenAlias() {
Client client = client();
createIndex("test1");
ClusterHealthResponse healthResponse = client.admin().cluster().prepareHealth().setWaitForGreenStatus().execute().actionGet();
assertThat(healthResponse.isTimedOut(), equalTo(false));
IndicesAliasesResponse aliasesResponse = client.admin().indices().prepareAliases().addAlias("test1", "test1-alias").execute().actionGet();
assertThat(aliasesResponse.isAcknowledged(), equalTo(true));
CloseIndexResponse closeIndexResponse = client.admin().indices().prepareClose("test1-alias").execute().actionGet();
assertThat(closeIndexResponse.isAcknowledged(), equalTo(true));
assertIndexIsClosed("test1");
OpenIndexResponse openIndexResponse = client.admin().indices().prepareOpen("test1-alias").execute().actionGet();
assertThat(openIndexResponse.isAcknowledged(), equalTo(true));
assertIndexIsOpened("test1");
}
use of org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse in project elasticsearch by elastic.
the class OpenCloseIndexIT method testCloseOpenAll.
public void testCloseOpenAll() {
Client client = client();
createIndex("test1", "test2", "test3");
ClusterHealthResponse healthResponse = client.admin().cluster().prepareHealth().setWaitForGreenStatus().execute().actionGet();
assertThat(healthResponse.isTimedOut(), equalTo(false));
CloseIndexResponse closeIndexResponse = client.admin().indices().prepareClose("_all").execute().actionGet();
assertThat(closeIndexResponse.isAcknowledged(), equalTo(true));
assertIndexIsClosed("test1", "test2", "test3");
OpenIndexResponse openIndexResponse = client.admin().indices().prepareOpen("_all").execute().actionGet();
assertThat(openIndexResponse.isAcknowledged(), equalTo(true));
assertIndexIsOpened("test1", "test2", "test3");
}
Aggregations