[ML] Removing usages of ToXContentParams.INCLUDE_TYPE (#48165)
Removing the option of ToXContentParams.INCLUDE_TYPE and replacing them with ToXContentParams.FOR_INTERNAL_STORAGE Closes #48057
This commit is contained in:
parent
6a97aef8ac
commit
5e4dd0fd2e
|
@ -111,7 +111,7 @@ public class Calendar implements ToXContentObject, Writeable {
|
||||||
if (description != null) {
|
if (description != null) {
|
||||||
builder.field(DESCRIPTION.getPreferredName(), description);
|
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.field(TYPE.getPreferredName(), CALENDAR_TYPE);
|
||||||
}
|
}
|
||||||
builder.endObject();
|
builder.endObject();
|
||||||
|
|
|
@ -167,7 +167,7 @@ public class ScheduledEvent implements ToXContentObject, Writeable {
|
||||||
if (eventId != null) {
|
if (eventId != null) {
|
||||||
builder.field(EVENT_ID.getPreferredName(), eventId);
|
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.field(TYPE.getPreferredName(), SCHEDULED_EVENT_TYPE);
|
||||||
}
|
}
|
||||||
builder.endObject();
|
builder.endObject();
|
||||||
|
|
|
@ -462,7 +462,7 @@ public class DatafeedConfig extends AbstractDiffable<DatafeedConfig> implements
|
||||||
builder.startObject();
|
builder.startObject();
|
||||||
builder.field(ID.getPreferredName(), id);
|
builder.field(ID.getPreferredName(), id);
|
||||||
builder.field(Job.ID.getPreferredName(), jobId);
|
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(CONFIG_TYPE.getPreferredName(), TYPE);
|
||||||
}
|
}
|
||||||
builder.field(QUERY_DELAY.getPreferredName(), queryDelay.getStringRep());
|
builder.field(QUERY_DELAY.getPreferredName(), queryDelay.getStringRep());
|
||||||
|
|
|
@ -228,7 +228,7 @@ public class DataFrameAnalyticsConfig implements ToXContentObject, Writeable {
|
||||||
builder.field(analysis.getWriteableName(), analysis);
|
builder.field(analysis.getWriteableName(), analysis);
|
||||||
builder.endObject();
|
builder.endObject();
|
||||||
|
|
||||||
if (params.paramAsBoolean(ToXContentParams.INCLUDE_TYPE, false)) {
|
if (params.paramAsBoolean(ToXContentParams.FOR_INTERNAL_STORAGE, false)) {
|
||||||
builder.field(CONFIG_TYPE.getPreferredName(), TYPE);
|
builder.field(CONFIG_TYPE.getPreferredName(), TYPE);
|
||||||
}
|
}
|
||||||
if (analyzedFields != null) {
|
if (analyzedFields != null) {
|
||||||
|
|
|
@ -101,7 +101,7 @@ public class MlFilter implements ToXContentObject, Writeable {
|
||||||
builder.field(DESCRIPTION.getPreferredName(), description);
|
builder.field(DESCRIPTION.getPreferredName(), description);
|
||||||
}
|
}
|
||||||
builder.field(ITEMS.getPreferredName(), items);
|
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.field(TYPE.getPreferredName(), FILTER_TYPE);
|
||||||
}
|
}
|
||||||
builder.endObject();
|
builder.endObject();
|
||||||
|
|
|
@ -18,12 +18,6 @@ public final class ToXContentParams {
|
||||||
*/
|
*/
|
||||||
public static final String FOR_INTERNAL_STORAGE = "for_internal_storage";
|
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
|
* When serialising POJOs to X Content this indicates whether the calculated (i.e. not stored) fields
|
||||||
* should be included or not
|
* should be included or not
|
||||||
|
|
|
@ -65,7 +65,7 @@ public class TransportPostCalendarEventsAction extends HandledTransportAction<Po
|
||||||
IndexRequest indexRequest = new IndexRequest(MlMetaIndex.INDEX_NAME);
|
IndexRequest indexRequest = new IndexRequest(MlMetaIndex.INDEX_NAME);
|
||||||
try (XContentBuilder builder = XContentFactory.jsonBuilder()) {
|
try (XContentBuilder builder = XContentFactory.jsonBuilder()) {
|
||||||
indexRequest.source(event.toXContent(builder,
|
indexRequest.source(event.toXContent(builder,
|
||||||
new ToXContent.MapParams(Collections.singletonMap(ToXContentParams.INCLUDE_TYPE,
|
new ToXContent.MapParams(Collections.singletonMap(ToXContentParams.FOR_INTERNAL_STORAGE,
|
||||||
"true"))));
|
"true"))));
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new IllegalStateException("Failed to serialise event", e);
|
throw new IllegalStateException("Failed to serialise event", e);
|
||||||
|
|
|
@ -50,7 +50,7 @@ public class TransportPutCalendarAction extends HandledTransportAction<PutCalend
|
||||||
IndexRequest indexRequest = new IndexRequest(MlMetaIndex.INDEX_NAME).id(calendar.documentId());
|
IndexRequest indexRequest = new IndexRequest(MlMetaIndex.INDEX_NAME).id(calendar.documentId());
|
||||||
try (XContentBuilder builder = XContentFactory.jsonBuilder()) {
|
try (XContentBuilder builder = XContentFactory.jsonBuilder()) {
|
||||||
indexRequest.source(calendar.toXContent(builder,
|
indexRequest.source(calendar.toXContent(builder,
|
||||||
new ToXContent.MapParams(Collections.singletonMap(ToXContentParams.INCLUDE_TYPE, "true"))));
|
new ToXContent.MapParams(Collections.singletonMap(ToXContentParams.FOR_INTERNAL_STORAGE, "true"))));
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new IllegalStateException("Failed to serialise calendar with id [" + calendar.getId() + "]", e);
|
throw new IllegalStateException("Failed to serialise calendar with id [" + calendar.getId() + "]", e);
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,7 +51,7 @@ public class TransportPutFilterAction extends HandledTransportAction<PutFilterAc
|
||||||
indexRequest.opType(DocWriteRequest.OpType.CREATE);
|
indexRequest.opType(DocWriteRequest.OpType.CREATE);
|
||||||
indexRequest.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE);
|
indexRequest.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE);
|
||||||
try (XContentBuilder builder = XContentFactory.jsonBuilder()) {
|
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));
|
indexRequest.source(filter.toXContent(builder, params));
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new IllegalStateException("Failed to serialise filter with id [" + filter.getId() + "]", e);
|
throw new IllegalStateException("Failed to serialise filter with id [" + filter.getId() + "]", e);
|
||||||
|
|
|
@ -107,7 +107,7 @@ public class TransportUpdateFilterAction extends HandledTransportAction<UpdateFi
|
||||||
indexRequest.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE);
|
indexRequest.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE);
|
||||||
|
|
||||||
try (XContentBuilder builder = XContentFactory.jsonBuilder()) {
|
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));
|
indexRequest.source(filter.toXContent(builder, params));
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new IllegalStateException("Failed to serialise filter with id [" + filter.getId() + "]", e);
|
throw new IllegalStateException("Failed to serialise filter with id [" + filter.getId() + "]", e);
|
||||||
|
|
|
@ -58,7 +58,6 @@ import java.io.InputStream;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -86,13 +85,7 @@ public class DatafeedConfigProvider {
|
||||||
private final Client client;
|
private final Client client;
|
||||||
private final NamedXContentRegistry xContentRegistry;
|
private final NamedXContentRegistry xContentRegistry;
|
||||||
|
|
||||||
public static final Map<String, String> TO_XCONTENT_PARAMS;
|
public static final Map<String, String> TO_XCONTENT_PARAMS = Collections.singletonMap(ToXContentParams.FOR_INTERNAL_STORAGE, "true");
|
||||||
static {
|
|
||||||
Map<String, String> modifiable = new HashMap<>();
|
|
||||||
modifiable.put(ToXContentParams.FOR_INTERNAL_STORAGE, "true");
|
|
||||||
modifiable.put(ToXContentParams.INCLUDE_TYPE, "true");
|
|
||||||
TO_XCONTENT_PARAMS = Collections.unmodifiableMap(modifiable);
|
|
||||||
}
|
|
||||||
|
|
||||||
public DatafeedConfigProvider(Client client, NamedXContentRegistry xContentRegistry) {
|
public DatafeedConfigProvider(Client client, NamedXContentRegistry xContentRegistry) {
|
||||||
this.client = client;
|
this.client = client;
|
||||||
|
|
|
@ -42,7 +42,6 @@ import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -59,14 +58,7 @@ public class DataFrameAnalyticsConfigProvider {
|
||||||
|
|
||||||
private static final int MAX_CONFIGS_SIZE = 10000;
|
private static final int MAX_CONFIGS_SIZE = 10000;
|
||||||
|
|
||||||
private static final Map<String, String> TO_XCONTENT_PARAMS;
|
private static final Map<String, String> TO_XCONTENT_PARAMS = Collections.singletonMap(ToXContentParams.FOR_INTERNAL_STORAGE, "true");
|
||||||
|
|
||||||
static {
|
|
||||||
Map<String, String> modifiable = new HashMap<>();
|
|
||||||
modifiable.put(ToXContentParams.INCLUDE_TYPE, "true");
|
|
||||||
modifiable.put(ToXContentParams.FOR_INTERNAL_STORAGE, "true");
|
|
||||||
TO_XCONTENT_PARAMS = Collections.unmodifiableMap(modifiable);
|
|
||||||
}
|
|
||||||
|
|
||||||
private final Client client;
|
private final Client client;
|
||||||
private final NamedXContentRegistry xContentRegistry;
|
private final NamedXContentRegistry xContentRegistry;
|
||||||
|
|
|
@ -563,7 +563,8 @@ public class JobResultsProviderIT extends MlSingleNodeTestCase {
|
||||||
for (ScheduledEvent event : events) {
|
for (ScheduledEvent event : events) {
|
||||||
IndexRequest indexRequest = new IndexRequest(MlMetaIndex.INDEX_NAME);
|
IndexRequest indexRequest = new IndexRequest(MlMetaIndex.INDEX_NAME);
|
||||||
try (XContentBuilder builder = XContentFactory.jsonBuilder()) {
|
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));
|
indexRequest.source(event.toXContent(builder, params));
|
||||||
bulkRequest.add(indexRequest);
|
bulkRequest.add(indexRequest);
|
||||||
}
|
}
|
||||||
|
@ -606,7 +607,8 @@ public class JobResultsProviderIT extends MlSingleNodeTestCase {
|
||||||
for (MlFilter filter : filters) {
|
for (MlFilter filter : filters) {
|
||||||
IndexRequest indexRequest = new IndexRequest(MlMetaIndex.INDEX_NAME).id(filter.documentId());
|
IndexRequest indexRequest = new IndexRequest(MlMetaIndex.INDEX_NAME).id(filter.documentId());
|
||||||
try (XContentBuilder builder = XContentFactory.jsonBuilder()) {
|
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));
|
indexRequest.source(filter.toXContent(builder, params));
|
||||||
bulkRequest.add(indexRequest);
|
bulkRequest.add(indexRequest);
|
||||||
}
|
}
|
||||||
|
@ -636,7 +638,8 @@ public class JobResultsProviderIT extends MlSingleNodeTestCase {
|
||||||
for (Calendar calendar: calendars) {
|
for (Calendar calendar: calendars) {
|
||||||
IndexRequest indexRequest = new IndexRequest(MlMetaIndex.INDEX_NAME).id(calendar.documentId());
|
IndexRequest indexRequest = new IndexRequest(MlMetaIndex.INDEX_NAME).id(calendar.documentId());
|
||||||
try (XContentBuilder builder = XContentFactory.jsonBuilder()) {
|
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));
|
indexRequest.source(calendar.toXContent(builder, params));
|
||||||
bulkRequest.add(indexRequest);
|
bulkRequest.add(indexRequest);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue