Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,7 @@ static Request getIndex(GetIndexRequest getIndexRequest) {
params.withIncludeDefaults(getIndexRequest.includeDefaults());
params.withHuman(getIndexRequest.humanReadable());
params.withMasterTimeout(getIndexRequest.masterNodeTimeout());
params.withIncludeTypeName(true);

return request;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
import org.elasticsearch.index.reindex.DeleteByQueryRequest;
import org.elasticsearch.index.reindex.ReindexRequest;
import org.elasticsearch.index.reindex.UpdateByQueryRequest;
import org.elasticsearch.rest.BaseRestHandler;
import org.elasticsearch.rest.action.search.RestSearchAction;
import org.elasticsearch.script.mustache.MultiSearchTemplateRequest;
import org.elasticsearch.script.mustache.SearchTemplateRequest;
Expand Down Expand Up @@ -930,6 +931,14 @@ Params withIncludeDefaults(boolean includeDefaults) {
return this;
}

Params withIncludeTypeName(boolean includeTypeName) {
if (includeTypeName) {
return putParam(BaseRestHandler.INCLUDE_TYPE_NAME_PARAMETER,
Boolean.toString(BaseRestHandler.DEFAULT_INCLUDE_TYPE_NAME_POLICY));
}
return this;
}

Params withPreserveExisting(boolean preserveExisting) {
if (preserveExisting) {
return putParam("preserve_existing", Boolean.TRUE.toString());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.common.util.CollectionUtils;
import org.elasticsearch.index.RandomCreateIndexGenerator;
import org.elasticsearch.rest.BaseRestHandler;
import org.elasticsearch.test.ESTestCase;
import org.junit.Assert;

Expand Down Expand Up @@ -364,6 +365,8 @@ public void testGetIndex() throws IOException {
RequestConvertersTests.setRandomIndicesOptions(getIndexRequest::indicesOptions, getIndexRequest::indicesOptions, expectedParams);
RequestConvertersTests.setRandomLocal(getIndexRequest, expectedParams);
RequestConvertersTests.setRandomHumanReadable(getIndexRequest, expectedParams);
// Force "include_type_name" parameter since responses need to be compatible when coming from 7.0 nodes
expectedParams.put(BaseRestHandler.INCLUDE_TYPE_NAME_PARAMETER, "true");

if (ESTestCase.randomBoolean()) {
// the request object will not have include_defaults present unless it is set to
Expand Down