Skip to content

Commit 707d1be

Browse files
committed
[ML] adding new flag exclude_generated that removes generated fields
When exporting and cloning ml configurations in a cluster it can be frustrating to remove all the fields that were generated by the plugin. Especially as the number of these fields change from version to version. This flag, remove_generated, allows the GET config APIs to return configurations with these generated fields removed. relates to elastic#63055
1 parent 71aaa4a commit 707d1be

File tree

26 files changed

+126
-118
lines changed

26 files changed

+126
-118
lines changed

client/rest-high-level/src/main/java/org/elasticsearch/client/MLRequestConverters.java

+6-6
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,8 @@ static Request getJob(GetJobRequest getJobRequest) {
123123
if (getJobRequest.getAllowNoMatch() != null) {
124124
params.putParam(GetJobRequest.ALLOW_NO_MATCH.getPreferredName(), Boolean.toString(getJobRequest.getAllowNoMatch()));
125125
}
126-
if (getJobRequest.getForExport() != null) {
127-
params.putParam(GetJobRequest.FOR_EXPORT, Boolean.toString(getJobRequest.getForExport()));
126+
if (getJobRequest.getExcludeGenerated() != null) {
127+
params.putParam(GetJobRequest.EXCLUDE_GENERATED, Boolean.toString(getJobRequest.getExcludeGenerated()));
128128
}
129129
request.addParameters(params.asMap());
130130
return request;
@@ -273,8 +273,8 @@ static Request getDatafeed(GetDatafeedRequest getDatafeedRequest) {
273273
params.putParam(GetDatafeedRequest.ALLOW_NO_MATCH.getPreferredName(),
274274
Boolean.toString(getDatafeedRequest.getAllowNoMatch()));
275275
}
276-
if (getDatafeedRequest.getForExport() != null) {
277-
params.putParam(GetDatafeedRequest.FOR_EXPORT, Boolean.toString(getDatafeedRequest.getForExport()));
276+
if (getDatafeedRequest.getExcludeGenerated() != null) {
277+
params.putParam(GetDatafeedRequest.EXCLUDE_GENERATED, Boolean.toString(getDatafeedRequest.getExcludeGenerated()));
278278
}
279279
request.addParameters(params.asMap());
280280
return request;
@@ -653,8 +653,8 @@ static Request getDataFrameAnalytics(GetDataFrameAnalyticsRequest getRequest) {
653653
if (getRequest.getAllowNoMatch() != null) {
654654
params.putParam(GetDataFrameAnalyticsRequest.ALLOW_NO_MATCH, Boolean.toString(getRequest.getAllowNoMatch()));
655655
}
656-
if (getRequest.getForExport() != null) {
657-
params.putParam(GetDataFrameAnalyticsRequest.FOR_EXPORT, Boolean.toString(getRequest.getForExport()));
656+
if (getRequest.getExcludeGenerated() != null) {
657+
params.putParam(GetDataFrameAnalyticsRequest.EXCLUDE_GENERATED, Boolean.toString(getRequest.getExcludeGenerated()));
658658
}
659659
request.addParameters(params.asMap());
660660
return request;

client/rest-high-level/src/main/java/org/elasticsearch/client/ml/GetDataFrameAnalyticsRequest.java

+9-9
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,12 @@
3232
public class GetDataFrameAnalyticsRequest implements Validatable {
3333

3434
public static final String ALLOW_NO_MATCH = "allow_no_match";
35-
public static final String FOR_EXPORT = "for_export";
35+
public static final String EXCLUDE_GENERATED = "exclude_generated";
3636

3737
private final List<String> ids;
3838
private Boolean allowNoMatch;
3939
private PageParams pageParams;
40-
private Boolean forExport;
40+
private Boolean excludeGenerated;
4141

4242
/**
4343
* Helper method to create a request that will get ALL Data Frame Analytics
@@ -65,14 +65,14 @@ public Boolean getAllowNoMatch() {
6565
* This is useful when getting the configuration and wanting to put it in another cluster.
6666
*
6767
* Default value is false.
68-
* @param forExport Boolean value indicating if certain fields should be removed
68+
* @param excludeGenerated Boolean value indicating if certain fields should be removed
6969
*/
70-
public void setForExport(boolean forExport) {
71-
this.forExport = forExport;
70+
public void setExcludeGenerated(boolean excludeGenerated) {
71+
this.excludeGenerated = excludeGenerated;
7272
}
7373

74-
public Boolean getForExport() {
75-
return forExport;
74+
public Boolean getExcludeGenerated() {
75+
return excludeGenerated;
7676
}
7777

7878
/**
@@ -111,12 +111,12 @@ public boolean equals(Object o) {
111111
GetDataFrameAnalyticsRequest other = (GetDataFrameAnalyticsRequest) o;
112112
return Objects.equals(ids, other.ids)
113113
&& Objects.equals(allowNoMatch, other.allowNoMatch)
114-
&& Objects.equals(forExport, other.forExport)
114+
&& Objects.equals(excludeGenerated, other.excludeGenerated)
115115
&& Objects.equals(pageParams, other.pageParams);
116116
}
117117

118118
@Override
119119
public int hashCode() {
120-
return Objects.hash(ids, allowNoMatch, forExport, pageParams);
120+
return Objects.hash(ids, allowNoMatch, excludeGenerated, pageParams);
121121
}
122122
}

client/rest-high-level/src/main/java/org/elasticsearch/client/ml/GetDatafeedRequest.java

+9-9
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,12 @@ public class GetDatafeedRequest implements Validatable, ToXContentObject {
4141

4242
public static final ParseField DATAFEED_IDS = new ParseField("datafeed_ids");
4343
public static final ParseField ALLOW_NO_MATCH = new ParseField("allow_no_match");
44-
public static final String FOR_EXPORT = "for_export";
44+
public static final String EXCLUDE_GENERATED = "exclude_generated";
4545

4646
private static final String ALL_DATAFEEDS = "_all";
4747
private final List<String> datafeedIds;
4848
private Boolean allowNoMatch;
49-
private Boolean forExport;
49+
private Boolean excludeGenerated;
5050

5151
@SuppressWarnings("unchecked")
5252
public static final ConstructingObjectParser<GetDatafeedRequest, Void> PARSER = new ConstructingObjectParser<>(
@@ -108,19 +108,19 @@ public Boolean getAllowNoMatch() {
108108
* This is useful when getting the configuration and wanting to put it in another cluster.
109109
*
110110
* Default value is false.
111-
* @param forExport Boolean value indicating if certain fields should be removed
111+
* @param excludeGenerated Boolean value indicating if certain fields should be removed
112112
*/
113-
public void setForExport(boolean forExport) {
114-
this.forExport = forExport;
113+
public void setExcludeGenerated(boolean excludeGenerated) {
114+
this.excludeGenerated = excludeGenerated;
115115
}
116116

117-
public Boolean getForExport() {
118-
return forExport;
117+
public Boolean getExcludeGenerated() {
118+
return excludeGenerated;
119119
}
120120

121121
@Override
122122
public int hashCode() {
123-
return Objects.hash(datafeedIds, forExport, allowNoMatch);
123+
return Objects.hash(datafeedIds, excludeGenerated, allowNoMatch);
124124
}
125125

126126
@Override
@@ -136,7 +136,7 @@ public boolean equals(Object other) {
136136
GetDatafeedRequest that = (GetDatafeedRequest) other;
137137
return Objects.equals(datafeedIds, that.datafeedIds) &&
138138
Objects.equals(allowNoMatch, that.allowNoMatch) &&
139-
Objects.equals(forExport, that.forExport);
139+
Objects.equals(excludeGenerated, that.excludeGenerated);
140140
}
141141

142142
@Override

client/rest-high-level/src/main/java/org/elasticsearch/client/ml/GetJobRequest.java

+9-9
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,12 @@ public class GetJobRequest implements Validatable, ToXContentObject {
4242

4343
public static final ParseField JOB_IDS = new ParseField("job_ids");
4444
public static final ParseField ALLOW_NO_MATCH = new ParseField("allow_no_match");
45-
public static final String FOR_EXPORT = "for_export";
45+
public static final String EXCLUDE_GENERATED = "exclude_generated";
4646

4747
private static final String ALL_JOBS = "_all";
4848
private final List<String> jobIds;
4949
private Boolean allowNoMatch;
50-
private Boolean forExport;
50+
private Boolean excludeGenerated;
5151

5252
@SuppressWarnings("unchecked")
5353
public static final ConstructingObjectParser<GetJobRequest, Void> PARSER = new ConstructingObjectParser<>(
@@ -108,19 +108,19 @@ public Boolean getAllowNoMatch() {
108108
* This is useful when getting the configuration and wanting to put it in another cluster.
109109
*
110110
* Default value is false.
111-
* @param forExport Boolean value indicating if certain fields should be removed
111+
* @param excludeGenerated Boolean value indicating if certain fields should be removed
112112
*/
113-
public void setForExport(boolean forExport) {
114-
this.forExport = forExport;
113+
public void setExcludeGenerated(boolean excludeGenerated) {
114+
this.excludeGenerated = excludeGenerated;
115115
}
116116

117-
public Boolean getForExport() {
118-
return forExport;
117+
public Boolean getExcludeGenerated() {
118+
return excludeGenerated;
119119
}
120120

121121
@Override
122122
public int hashCode() {
123-
return Objects.hash(jobIds, forExport, allowNoMatch);
123+
return Objects.hash(jobIds, excludeGenerated, allowNoMatch);
124124
}
125125

126126
@Override
@@ -135,7 +135,7 @@ public boolean equals(Object other) {
135135

136136
GetJobRequest that = (GetJobRequest) other;
137137
return Objects.equals(jobIds, that.jobIds) &&
138-
Objects.equals(forExport, that.forExport) &&
138+
Objects.equals(excludeGenerated, that.excludeGenerated) &&
139139
Objects.equals(allowNoMatch, that.allowNoMatch);
140140
}
141141

client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/MlClientDocumentationIT.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ public void testGetJob() throws Exception {
342342
// tag::get-job-request
343343
GetJobRequest request = new GetJobRequest("get-machine-learning-job1", "get-machine-learning-job*"); // <1>
344344
request.setAllowNoMatch(true); // <2>
345-
request.setForExport(false); // <3>
345+
request.setExcludeGenerated(false); // <3>
346346
// end::get-job-request
347347

348348
// tag::get-job-execute
@@ -839,7 +839,7 @@ public void testGetDatafeed() throws Exception {
839839
// tag::get-datafeed-request
840840
GetDatafeedRequest request = new GetDatafeedRequest(datafeedId); // <1>
841841
request.setAllowNoMatch(true); // <2>
842-
request.setForExport(false); // <3>
842+
request.setExcludeGenerated(false); // <3>
843843
// end::get-datafeed-request
844844

845845
// tag::get-datafeed-execute
@@ -2865,7 +2865,7 @@ public void testGetDataFrameAnalytics() throws Exception {
28652865
{
28662866
// tag::get-data-frame-analytics-request
28672867
GetDataFrameAnalyticsRequest request = new GetDataFrameAnalyticsRequest("my-analytics-config"); // <1>
2868-
request.setForExport(false); // <2>
2868+
request.setExcludeGenerated(false); // <2>
28692869
// end::get-data-frame-analytics-request
28702870

28712871
// tag::get-data-frame-analytics-execute

docs/reference/ml/anomaly-detection/apis/get-datafeed.asciidoc

+4-4
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Retrieves configuration information for {dfeeds}.
1919

2020
`GET _ml/datafeeds/` +
2121

22-
`GET _ml/datafeeds/_all`
22+
`GET _ml/datafeeds/_all`
2323

2424
[[ml-get-datafeed-prereqs]]
2525
== {api-prereq-title}
@@ -36,7 +36,7 @@ comma-separated list of {dfeeds} or a wildcard expression. You can get
3636
information for all {dfeeds} by using `_all`, by specifying `*` as the
3737
`<feed_id>`, or by omitting the `<feed_id>`.
3838

39-
IMPORTANT: This API returns a maximum of 10,000 {dfeeds}.
39+
IMPORTANT: This API returns a maximum of 10,000 {dfeeds}.
4040

4141
[[ml-get-datafeed-path-parms]]
4242
== {api-path-parms-title}
@@ -57,9 +57,9 @@ all {dfeeds}.
5757
(Optional, boolean)
5858
include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=allow-no-datafeeds]
5959

60-
`for_export`::
60+
`exclude_generated`::
6161
(Optional, boolean)
62-
include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=for-export]
62+
include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=exclude-generated]
6363

6464
[[ml-get-datafeed-results]]
6565
== {api-response-body-title}

docs/reference/ml/anomaly-detection/apis/get-job.asciidoc

+5-5
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ using a group name, a comma-separated list of jobs, or a wildcard expression.
3434
You can get information for all {anomaly-jobs} by using `_all`, by specifying
3535
`*` as the `<job_id>`, or by omitting the `<job_id>`.
3636

37-
IMPORTANT: This API returns a maximum of 10,000 jobs.
37+
IMPORTANT: This API returns a maximum of 10,000 jobs.
3838

3939
[[ml-get-job-path-parms]]
4040
== {api-path-parms-title}
@@ -50,9 +50,9 @@ include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=job-id-anomaly-detection-defaul
5050
(Optional, boolean)
5151
include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=allow-no-jobs]
5252

53-
`for_export`::
53+
`exclude_generated`::
5454
(Optional, boolean)
55-
include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=for-export]
55+
include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=exclude-generated]
5656

5757
[[ml-get-job-results]]
5858
== {api-response-body-title}
@@ -63,7 +63,7 @@ properties, see <<ml-put-job-request-body,create {anomaly-jobs} API>>.
6363
`create_time`::
6464
(string) The time the job was created. For example, `1491007356077`. This
6565
property is informational; you cannot change its value.
66-
66+
6767
`finished_time`::
6868
(string) If the job closed or failed, this is the time the job finished,
6969
otherwise it is `null`. This property is informational; you cannot change its
@@ -83,7 +83,7 @@ include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=model-snapshot-id]
8383
== {api-response-codes-title}
8484

8585
`404` (Missing resources)::
86-
If `allow_no_match` is `false`, this code indicates that there are no
86+
If `allow_no_match` is `false`, this code indicates that there are no
8787
resources that match the request or only partial matches for the request.
8888

8989
[[ml-get-job-example]]

0 commit comments

Comments
 (0)