use of org.elasticsearch.action.admin.cluster.shards.ClusterSearchShardsResponse in project elasticsearch by elastic.
the class ClusterSearchShardsIT method testMultipleShardsSingleNodeAllocation.
public void testMultipleShardsSingleNodeAllocation() throws Exception {
client().admin().indices().prepareCreate("test").setSettings(Settings.builder().put("index.number_of_shards", "4").put("index.number_of_replicas", 0).put("index.routing.allocation.include.tag", "A")).execute().actionGet();
ensureGreen();
ClusterSearchShardsResponse response = client().admin().cluster().prepareSearchShards("test").execute().actionGet();
assertThat(response.getGroups().length, equalTo(4));
assertThat(response.getGroups()[0].getShardId().getIndexName(), equalTo("test"));
assertThat(response.getNodes().length, equalTo(1));
assertThat(response.getGroups()[0].getShards()[0].currentNodeId(), equalTo(response.getNodes()[0].getId()));
response = client().admin().cluster().prepareSearchShards("test").setRouting("ABC").execute().actionGet();
assertThat(response.getGroups().length, equalTo(1));
response = client().admin().cluster().prepareSearchShards("test").setPreference("_shards:2").execute().actionGet();
assertThat(response.getGroups().length, equalTo(1));
assertThat(response.getGroups()[0].getShardId().getId(), equalTo(2));
}
Aggregations