3333import org .elasticsearch .action .admin .indices .flush .FlushRequest ;
3434import org .elasticsearch .action .admin .indices .flush .SyncedFlushRequest ;
3535import org .elasticsearch .action .admin .indices .forcemerge .ForceMergeRequest ;
36- import org .elasticsearch .action .admin .indices .get .GetIndexRequest ;
37- import org .elasticsearch .client .indices .GetFieldMappingsRequest ;
3836import org .elasticsearch .action .admin .indices .open .OpenIndexRequest ;
3937import org .elasticsearch .action .admin .indices .refresh .RefreshRequest ;
4038import org .elasticsearch .action .admin .indices .settings .get .GetSettingsRequest ;
4644import org .elasticsearch .action .support .ActiveShardCount ;
4745import org .elasticsearch .client .indices .CreateIndexRequest ;
4846import org .elasticsearch .client .indices .FreezeIndexRequest ;
47+ import org .elasticsearch .client .indices .GetFieldMappingsRequest ;
48+ import org .elasticsearch .client .indices .GetIndexRequest ;
4949import org .elasticsearch .client .indices .GetIndexTemplatesRequest ;
5050import org .elasticsearch .client .indices .GetMappingsRequest ;
5151import org .elasticsearch .client .indices .IndexTemplatesExistRequest ;
5454import org .elasticsearch .client .indices .UnfreezeIndexRequest ;
5555import org .elasticsearch .client .indices .rollover .RolloverRequest ;
5656import org .elasticsearch .common .Strings ;
57- import org .elasticsearch .rest .BaseRestHandler ;
5857
5958import java .io .IOException ;
6059import java .util .Locale ;
@@ -152,6 +151,10 @@ static Request putMapping(PutMappingRequest putMappingRequest) throws IOExceptio
152151 return request ;
153152 }
154153
154+ /**
155+ * converter for the legacy server-side {@link org.elasticsearch.action.admin.indices.mapping.put.PutMappingRequest} that still supports
156+ * types
157+ */
155158 @ Deprecated
156159 static Request putMapping (org .elasticsearch .action .admin .indices .mapping .put .PutMappingRequest putMappingRequest ) throws IOException {
157160 // The concreteIndex is an internal concept, not applicable to requests made over the REST API.
@@ -396,6 +399,28 @@ static Request getSettings(GetSettingsRequest getSettingsRequest) {
396399 return request ;
397400 }
398401
402+ /**
403+ * converter for the legacy server-side {@link org.elasticsearch.action.admin.indices.get.GetIndexRequest} that
404+ * still supports types
405+ */
406+ @ Deprecated
407+ static Request getIndex (org .elasticsearch .action .admin .indices .get .GetIndexRequest getIndexRequest ) {
408+ String [] indices = getIndexRequest .indices () == null ? Strings .EMPTY_ARRAY : getIndexRequest .indices ();
409+
410+ String endpoint = RequestConverters .endpoint (indices );
411+ Request request = new Request (HttpGet .METHOD_NAME , endpoint );
412+
413+ RequestConverters .Params params = new RequestConverters .Params (request );
414+ params .withIndicesOptions (getIndexRequest .indicesOptions ());
415+ params .withLocal (getIndexRequest .local ());
416+ params .withIncludeDefaults (getIndexRequest .includeDefaults ());
417+ params .withHuman (getIndexRequest .humanReadable ());
418+ params .withMasterTimeout (getIndexRequest .masterNodeTimeout ());
419+ params .putParam (INCLUDE_TYPE_NAME_PARAMETER , Boolean .TRUE .toString ());
420+
421+ return request ;
422+ }
423+
399424 static Request getIndex (GetIndexRequest getIndexRequest ) {
400425 String [] indices = getIndexRequest .indices () == null ? Strings .EMPTY_ARRAY : getIndexRequest .indices ();
401426
@@ -408,12 +433,33 @@ static Request getIndex(GetIndexRequest getIndexRequest) {
408433 params .withIncludeDefaults (getIndexRequest .includeDefaults ());
409434 params .withHuman (getIndexRequest .humanReadable ());
410435 params .withMasterTimeout (getIndexRequest .masterNodeTimeout ());
411- // Force "include_type_name" parameter since responses need to be compatible when coming from 7.0 nodes
412- params .putParam (BaseRestHandler .INCLUDE_TYPE_NAME_PARAMETER , Boolean .TRUE .toString ());
436+ params .putParam (INCLUDE_TYPE_NAME_PARAMETER , Boolean .FALSE .toString ());
413437
414438 return request ;
415439 }
416440
441+ /**
442+ * converter for the legacy server-side {@link org.elasticsearch.action.admin.indices.get.GetIndexRequest} that
443+ * still supports types
444+ */
445+ @ Deprecated
446+ static Request indicesExist (org .elasticsearch .action .admin .indices .get .GetIndexRequest getIndexRequest ) {
447+ // this can be called with no indices as argument by transport client, not via REST though
448+ if (getIndexRequest .indices () == null || getIndexRequest .indices ().length == 0 ) {
449+ throw new IllegalArgumentException ("indices are mandatory" );
450+ }
451+ String endpoint = RequestConverters .endpoint (getIndexRequest .indices (), "" );
452+ Request request = new Request (HttpHead .METHOD_NAME , endpoint );
453+
454+ RequestConverters .Params params = new RequestConverters .Params (request );
455+ params .withLocal (getIndexRequest .local ());
456+ params .withHuman (getIndexRequest .humanReadable ());
457+ params .withIndicesOptions (getIndexRequest .indicesOptions ());
458+ params .withIncludeDefaults (getIndexRequest .includeDefaults ());
459+ params .putParam (INCLUDE_TYPE_NAME_PARAMETER , Boolean .TRUE .toString ());
460+ return request ;
461+ }
462+
417463 static Request indicesExist (GetIndexRequest getIndexRequest ) {
418464 // this can be called with no indices as argument by transport client, not via REST though
419465 if (getIndexRequest .indices () == null || getIndexRequest .indices ().length == 0 ) {
@@ -427,6 +473,7 @@ static Request indicesExist(GetIndexRequest getIndexRequest) {
427473 params .withHuman (getIndexRequest .humanReadable ());
428474 params .withIndicesOptions (getIndexRequest .indicesOptions ());
429475 params .withIncludeDefaults (getIndexRequest .includeDefaults ());
476+ params .putParam (INCLUDE_TYPE_NAME_PARAMETER , Boolean .FALSE .toString ());
430477 return request ;
431478 }
432479
@@ -445,18 +492,18 @@ static Request indexPutSettings(UpdateSettingsRequest updateSettingsRequest) thr
445492 }
446493
447494 /**
448- * @deprecated This uses the old form of PutIndexTemplateRequest which uses types.
495+ * @deprecated This uses the old form of PutIndexTemplateRequest which uses types.
449496 * Use (@link {@link #putTemplate(PutIndexTemplateRequest)} instead
450497 */
451498 @ Deprecated
452- static Request putTemplate (org .elasticsearch .action .admin .indices .template .put .PutIndexTemplateRequest putIndexTemplateRequest )
499+ static Request putTemplate (org .elasticsearch .action .admin .indices .template .put .PutIndexTemplateRequest putIndexTemplateRequest )
453500 throws IOException {
454501 String endpoint = new RequestConverters .EndpointBuilder ().addPathPartAsIs ("_template" )
455502 .addPathPart (putIndexTemplateRequest .name ()).build ();
456503 Request request = new Request (HttpPut .METHOD_NAME , endpoint );
457504 RequestConverters .Params params = new RequestConverters .Params (request );
458505 params .withMasterTimeout (putIndexTemplateRequest .masterNodeTimeout ());
459- params .putParam (BaseRestHandler . INCLUDE_TYPE_NAME_PARAMETER , Boolean .TRUE .toString ());
506+ params .putParam (INCLUDE_TYPE_NAME_PARAMETER , Boolean .TRUE .toString ());
460507 if (putIndexTemplateRequest .create ()) {
461508 params .putParam ("create" , Boolean .TRUE .toString ());
462509 }
@@ -474,7 +521,7 @@ static Request putTemplate(PutIndexTemplateRequest putIndexTemplateRequest) thro
474521 RequestConverters .Params params = new RequestConverters .Params (request );
475522 params .withMasterTimeout (putIndexTemplateRequest .masterNodeTimeout ());
476523 if (putIndexTemplateRequest .mappings () != null ) {
477- params .putParam (BaseRestHandler . INCLUDE_TYPE_NAME_PARAMETER , Boolean .FALSE .toString ());
524+ params .putParam (INCLUDE_TYPE_NAME_PARAMETER , Boolean .FALSE .toString ());
478525 }
479526 if (putIndexTemplateRequest .create ()) {
480527 params .putParam ("create" , Boolean .TRUE .toString ());
@@ -515,11 +562,11 @@ static Request getAlias(GetAliasesRequest getAliasesRequest) {
515562 static Request getTemplatesWithDocumentTypes (GetIndexTemplatesRequest getIndexTemplatesRequest ) {
516563 return getTemplates (getIndexTemplatesRequest , true );
517564 }
518-
565+
519566 static Request getTemplates (GetIndexTemplatesRequest getIndexTemplatesRequest ) {
520567 return getTemplates (getIndexTemplatesRequest , false );
521568 }
522-
569+
523570 private static Request getTemplates (GetIndexTemplatesRequest getIndexTemplatesRequest , boolean includeTypeName ) {
524571 final String endpoint = new RequestConverters .EndpointBuilder ()
525572 .addPathPartAsIs ("_template" )
@@ -529,9 +576,9 @@ private static Request getTemplates(GetIndexTemplatesRequest getIndexTemplatesRe
529576 final RequestConverters .Params params = new RequestConverters .Params (request );
530577 params .withLocal (getIndexTemplatesRequest .isLocal ());
531578 params .withMasterTimeout (getIndexTemplatesRequest .getMasterNodeTimeout ());
532- params .putParam (BaseRestHandler . INCLUDE_TYPE_NAME_PARAMETER , Boolean .toString (includeTypeName ));
579+ params .putParam (INCLUDE_TYPE_NAME_PARAMETER , Boolean .toString (includeTypeName ));
533580 return request ;
534- }
581+ }
535582
536583 static Request templatesExist (IndexTemplatesExistRequest indexTemplatesExistRequest ) {
537584 final String endpoint = new RequestConverters .EndpointBuilder ()
0 commit comments