diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/IndicesClientIT.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/IndicesClientIT.java index 59d76142566e6..a050693e04c02 100644 --- a/client/rest-high-level/src/test/java/org/elasticsearch/client/IndicesClientIT.java +++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/IndicesClientIT.java @@ -192,8 +192,7 @@ public void testIndicesExistsWithTypes() throws IOException { = new org.elasticsearch.action.admin.indices.get.GetIndexRequest(); request.indices(indexName); - boolean response = execute(request, highLevelClient().indices()::exists, highLevelClient().indices()::existsAsync, - expectWarnings(RestGetIndicesAction.TYPES_DEPRECATION_MESSAGE)); + boolean response = execute(request, highLevelClient().indices()::exists, highLevelClient().indices()::existsAsync); assertTrue(response); } diff --git a/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestGetIndicesAction.java b/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestGetIndicesAction.java index 842741872fdb2..6649863e8520e 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestGetIndicesAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestGetIndicesAction.java @@ -70,8 +70,8 @@ public String getName() { @Override public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException { String[] indices = Strings.splitStringByCommaToArray(request.param("index")); - // starting with 7.0 we don't include types by default in the response - if (request.hasParam(INCLUDE_TYPE_NAME_PARAMETER)) { + // starting with 7.0 we don't include types by default in the response to GET requests + if (request.hasParam(INCLUDE_TYPE_NAME_PARAMETER) && request.method().equals(GET)) { deprecationLogger.deprecatedAndMaybeLog("get_indices_with_types", TYPES_DEPRECATION_MESSAGE); } final GetIndexRequest getIndexRequest = new GetIndexRequest(); diff --git a/server/src/test/java/org/elasticsearch/rest/action/admin/indices/RestGetIndicesActionTests.java b/server/src/test/java/org/elasticsearch/rest/action/admin/indices/RestGetIndicesActionTests.java index e4eb0edbb8582..3490e8f2c8844 100644 --- a/server/src/test/java/org/elasticsearch/rest/action/admin/indices/RestGetIndicesActionTests.java +++ b/server/src/test/java/org/elasticsearch/rest/action/admin/indices/RestGetIndicesActionTests.java @@ -36,7 +36,7 @@ public class RestGetIndicesActionTests extends RestActionTestCase { /** - * Test that setting the "include_type_name" parameter raises a warning + * Test that setting the "include_type_name" parameter raises a warning for the GET request */ public void testIncludeTypeNamesWarning() throws IOException { Map params = new HashMap<>(); @@ -58,4 +58,20 @@ public void testIncludeTypeNamesWarning() throws IOException { .build(); handler.prepareRequest(request, mock(NodeClient.class)); } + + /** + * Test that setting the "include_type_name" parameter doesn't raises a warning if the HEAD method is used (indices.exists) + */ + public void testIncludeTypeNamesWarningExists() throws IOException { + Map params = new HashMap<>(); + params.put(INCLUDE_TYPE_NAME_PARAMETER, randomFrom("true", "false")); + RestRequest request = new FakeRestRequest.Builder(xContentRegistry()) + .withMethod(RestRequest.Method.HEAD) + .withPath("/some_index") + .withParams(params) + .build(); + + RestGetIndicesAction handler = new RestGetIndicesAction(Settings.EMPTY, mock(RestController.class)); + handler.prepareRequest(request, mock(NodeClient.class)); + } }