Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<String, String> params = new HashMap<>();
Expand All @@ -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<String, String> 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));
}
}