diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/calendars/Calendar.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/calendars/Calendar.java index 723f1b5c8b7..895abb6ee7b 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/calendars/Calendar.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/calendars/Calendar.java @@ -111,7 +111,7 @@ public class Calendar implements ToXContentObject, Writeable { if (description != null) { builder.field(DESCRIPTION.getPreferredName(), description); } - if (params.paramAsBoolean(ToXContentParams.INCLUDE_TYPE, false)) { + if (params.paramAsBoolean(ToXContentParams.FOR_INTERNAL_STORAGE, false)) { builder.field(TYPE.getPreferredName(), CALENDAR_TYPE); } builder.endObject(); diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/calendars/ScheduledEvent.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/calendars/ScheduledEvent.java index fe067d9969e..fe628c7ff4c 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/calendars/ScheduledEvent.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/calendars/ScheduledEvent.java @@ -167,7 +167,7 @@ public class ScheduledEvent implements ToXContentObject, Writeable { if (eventId != null) { builder.field(EVENT_ID.getPreferredName(), eventId); } - if (params.paramAsBoolean(ToXContentParams.INCLUDE_TYPE, false)) { + if (params.paramAsBoolean(ToXContentParams.FOR_INTERNAL_STORAGE, false)) { builder.field(TYPE.getPreferredName(), SCHEDULED_EVENT_TYPE); } builder.endObject(); diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/datafeed/DatafeedConfig.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/datafeed/DatafeedConfig.java index 057c03161d8..4e8a18bf45c 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/datafeed/DatafeedConfig.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/datafeed/DatafeedConfig.java @@ -462,7 +462,7 @@ public class DatafeedConfig extends AbstractDiffable implements builder.startObject(); builder.field(ID.getPreferredName(), id); builder.field(Job.ID.getPreferredName(), jobId); - if (params.paramAsBoolean(ToXContentParams.INCLUDE_TYPE, false) == true) { + if (params.paramAsBoolean(ToXContentParams.FOR_INTERNAL_STORAGE, false) == true) { builder.field(CONFIG_TYPE.getPreferredName(), TYPE); } builder.field(QUERY_DELAY.getPreferredName(), queryDelay.getStringRep()); diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/dataframe/DataFrameAnalyticsConfig.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/dataframe/DataFrameAnalyticsConfig.java index 6788fdaf7c8..e97a7ca03b3 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/dataframe/DataFrameAnalyticsConfig.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/dataframe/DataFrameAnalyticsConfig.java @@ -228,7 +228,7 @@ public class DataFrameAnalyticsConfig implements ToXContentObject, Writeable { builder.field(analysis.getWriteableName(), analysis); builder.endObject(); - if (params.paramAsBoolean(ToXContentParams.INCLUDE_TYPE, false)) { + if (params.paramAsBoolean(ToXContentParams.FOR_INTERNAL_STORAGE, false)) { builder.field(CONFIG_TYPE.getPreferredName(), TYPE); } if (analyzedFields != null) { diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/config/MlFilter.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/config/MlFilter.java index f2be3315b4d..a3967520c54 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/config/MlFilter.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/config/MlFilter.java @@ -101,7 +101,7 @@ public class MlFilter implements ToXContentObject, Writeable { builder.field(DESCRIPTION.getPreferredName(), description); } builder.field(ITEMS.getPreferredName(), items); - if (params.paramAsBoolean(ToXContentParams.INCLUDE_TYPE, false)) { + if (params.paramAsBoolean(ToXContentParams.FOR_INTERNAL_STORAGE, false)) { builder.field(TYPE.getPreferredName(), FILTER_TYPE); } builder.endObject(); @@ -201,4 +201,4 @@ public class MlFilter implements ToXContentObject, Writeable { return new MlFilter(id, description, items); } } -} \ No newline at end of file +} diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/utils/ToXContentParams.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/utils/ToXContentParams.java index 249a319823c..84a4c26d439 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/utils/ToXContentParams.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/utils/ToXContentParams.java @@ -18,12 +18,6 @@ public final class ToXContentParams { */ public static final String FOR_INTERNAL_STORAGE = "for_internal_storage"; - /** - * When serialising POJOs to X Content this indicates whether the type field - * should be included or not - */ - public static final String INCLUDE_TYPE = "include_type"; - /** * When serialising POJOs to X Content this indicates whether the calculated (i.e. not stored) fields * should be included or not diff --git a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportPostCalendarEventsAction.java b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportPostCalendarEventsAction.java index fdb5bb6ec09..de664950574 100644 --- a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportPostCalendarEventsAction.java +++ b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportPostCalendarEventsAction.java @@ -65,7 +65,7 @@ public class TransportPostCalendarEventsAction extends HandledTransportAction TO_XCONTENT_PARAMS; - static { - Map modifiable = new HashMap<>(); - modifiable.put(ToXContentParams.FOR_INTERNAL_STORAGE, "true"); - modifiable.put(ToXContentParams.INCLUDE_TYPE, "true"); - TO_XCONTENT_PARAMS = Collections.unmodifiableMap(modifiable); - } + public static final Map TO_XCONTENT_PARAMS = Collections.singletonMap(ToXContentParams.FOR_INTERNAL_STORAGE, "true"); public DatafeedConfigProvider(Client client, NamedXContentRegistry xContentRegistry) { this.client = client; diff --git a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/dataframe/persistence/DataFrameAnalyticsConfigProvider.java b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/dataframe/persistence/DataFrameAnalyticsConfigProvider.java index d13ed2c6a4d..8b55932a253 100644 --- a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/dataframe/persistence/DataFrameAnalyticsConfigProvider.java +++ b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/dataframe/persistence/DataFrameAnalyticsConfigProvider.java @@ -42,7 +42,6 @@ import java.io.IOException; import java.io.InputStream; import java.util.ArrayList; import java.util.Collections; -import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; @@ -59,14 +58,7 @@ public class DataFrameAnalyticsConfigProvider { private static final int MAX_CONFIGS_SIZE = 10000; - private static final Map TO_XCONTENT_PARAMS; - - static { - Map modifiable = new HashMap<>(); - modifiable.put(ToXContentParams.INCLUDE_TYPE, "true"); - modifiable.put(ToXContentParams.FOR_INTERNAL_STORAGE, "true"); - TO_XCONTENT_PARAMS = Collections.unmodifiableMap(modifiable); - } + private static final Map TO_XCONTENT_PARAMS = Collections.singletonMap(ToXContentParams.FOR_INTERNAL_STORAGE, "true"); private final Client client; private final NamedXContentRegistry xContentRegistry; diff --git a/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/integration/JobResultsProviderIT.java b/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/integration/JobResultsProviderIT.java index 3c62db210f7..5fc608da9fe 100644 --- a/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/integration/JobResultsProviderIT.java +++ b/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/integration/JobResultsProviderIT.java @@ -563,7 +563,8 @@ public class JobResultsProviderIT extends MlSingleNodeTestCase { for (ScheduledEvent event : events) { IndexRequest indexRequest = new IndexRequest(MlMetaIndex.INDEX_NAME); try (XContentBuilder builder = XContentFactory.jsonBuilder()) { - ToXContent.MapParams params = new ToXContent.MapParams(Collections.singletonMap(ToXContentParams.INCLUDE_TYPE, "true")); + ToXContent.MapParams params = new ToXContent.MapParams(Collections.singletonMap( + ToXContentParams.FOR_INTERNAL_STORAGE, "true")); indexRequest.source(event.toXContent(builder, params)); bulkRequest.add(indexRequest); } @@ -606,7 +607,8 @@ public class JobResultsProviderIT extends MlSingleNodeTestCase { for (MlFilter filter : filters) { IndexRequest indexRequest = new IndexRequest(MlMetaIndex.INDEX_NAME).id(filter.documentId()); try (XContentBuilder builder = XContentFactory.jsonBuilder()) { - ToXContent.MapParams params = new ToXContent.MapParams(Collections.singletonMap(ToXContentParams.INCLUDE_TYPE, "true")); + ToXContent.MapParams params = new ToXContent.MapParams(Collections.singletonMap( + ToXContentParams.FOR_INTERNAL_STORAGE, "true")); indexRequest.source(filter.toXContent(builder, params)); bulkRequest.add(indexRequest); } @@ -636,7 +638,8 @@ public class JobResultsProviderIT extends MlSingleNodeTestCase { for (Calendar calendar: calendars) { IndexRequest indexRequest = new IndexRequest(MlMetaIndex.INDEX_NAME).id(calendar.documentId()); try (XContentBuilder builder = XContentFactory.jsonBuilder()) { - ToXContent.MapParams params = new ToXContent.MapParams(Collections.singletonMap(ToXContentParams.INCLUDE_TYPE, "true")); + ToXContent.MapParams params = new ToXContent.MapParams( + Collections.singletonMap(ToXContentParams.FOR_INTERNAL_STORAGE, "true")); indexRequest.source(calendar.toXContent(builder, params)); bulkRequest.add(indexRequest); }