diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/ClusterClientIT.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/ClusterClientIT.java index 2ae6f9dc186..2a870ec65ee 100644 --- a/client/rest-high-level/src/test/java/org/elasticsearch/client/ClusterClientIT.java +++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/ClusterClientIT.java @@ -129,7 +129,6 @@ public class ClusterClientIT extends ESRestHighLevelClientTestCase { createIndex("index2", Settings.EMPTY); ClusterHealthRequest request = new ClusterHealthRequest(); request.timeout("5s"); - request.level(ClusterHealthRequest.Level.CLUSTER); ClusterHealthResponse response = execute(request, highLevelClient().cluster()::health, highLevelClient().cluster()::healthAsync); assertYellowShards(response); @@ -170,6 +169,7 @@ public class ClusterClientIT extends ESRestHighLevelClientTestCase { createIndex("index", Settings.EMPTY); createIndex("index2", Settings.EMPTY); ClusterHealthRequest request = new ClusterHealthRequest("index"); + request.level(ClusterHealthRequest.Level.SHARDS); request.timeout("5s"); ClusterHealthResponse response = execute(request, highLevelClient().cluster()::health, highLevelClient().cluster()::healthAsync); diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/RequestConvertersTests.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/RequestConvertersTests.java index 5bc9bac96dc..aa8221f3099 100644 --- a/client/rest-high-level/src/test/java/org/elasticsearch/client/RequestConvertersTests.java +++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/RequestConvertersTests.java @@ -1568,7 +1568,7 @@ public class RequestConvertersTests extends ESTestCase { healthRequest.level(level); expectedParams.put("level", level.name().toLowerCase(Locale.ROOT)); } else { - expectedParams.put("level", "shards"); + expectedParams.put("level", "cluster"); } if (randomBoolean()) { Priority priority = randomFrom(Priority.values()); diff --git a/docs/java-rest/high-level/cluster/health.asciidoc b/docs/java-rest/high-level/cluster/health.asciidoc index 6c0f926f15f..192880849e2 100644 --- a/docs/java-rest/high-level/cluster/health.asciidoc +++ b/docs/java-rest/high-level/cluster/health.asciidoc @@ -67,6 +67,7 @@ include-tagged::{doc-tests}/ClusterClientDocumentationIT.java[health-request-wai include-tagged::{doc-tests}/ClusterClientDocumentationIT.java[health-request-level] -------------------------------------------------- <1> The level of detail of the returned health information. Accepts a `ClusterHealthRequest.Level` value. +Default value is `cluster`. ["source","java",subs="attributes,callouts,macros"] -------------------------------------------------- diff --git a/docs/reference/migration/migrate_7_0/restclient.asciidoc b/docs/reference/migration/migrate_7_0/restclient.asciidoc index 146b0d73386..470996cfeff 100644 --- a/docs/reference/migration/migrate_7_0/restclient.asciidoc +++ b/docs/reference/migration/migrate_7_0/restclient.asciidoc @@ -10,4 +10,11 @@ header, e.g. `client.index(indexRequest)` becomes `client.index(indexRequest, RequestOptions.DEFAULT)`. In case you are specifying headers e.g. `client.index(indexRequest, new Header("name" "value"))` becomes -`client.index(indexRequest, RequestOptions.DEFAULT.toBuilder().addHeader("name", "value").build());` \ No newline at end of file +`client.index(indexRequest, RequestOptions.DEFAULT.toBuilder().addHeader("name", "value").build());` + +==== Cluster Health API default to `cluster` level + +The Cluster Health API used to default to `shards` level to ease migration +from transport client that doesn't support the `level` parameter and always +returns information including indices and shards details. The level default +value has been aligned with the Elasticsearch default level: `cluster`. \ No newline at end of file diff --git a/server/src/main/java/org/elasticsearch/action/admin/cluster/health/ClusterHealthRequest.java b/server/src/main/java/org/elasticsearch/action/admin/cluster/health/ClusterHealthRequest.java index 59a291888d0..0b9bcbf11b9 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/cluster/health/ClusterHealthRequest.java +++ b/server/src/main/java/org/elasticsearch/action/admin/cluster/health/ClusterHealthRequest.java @@ -48,9 +48,9 @@ public class ClusterHealthRequest extends MasterNodeReadRequest