Skip to content

Commit

Permalink
Verify that create_time and version fields appear on GET
Browse files Browse the repository at this point in the history
  • Loading branch information
przemekwitek committed Jun 27, 2019
1 parent 49afd63 commit a0d487e
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,8 @@ public Builder(DataFrameAnalyticsConfig config, ByteSizeValue maxModelMemoryLimi
if (config.analyzedFields != null) {
this.analyzedFields = new FetchSourceContext(true, config.analyzedFields.includes(), config.analyzedFields.excludes());
}
this.createTime = config.createTime;
this.version = config.version;
}

public String getId() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,10 @@ public static void addDatafeedConfigFields(XContentBuilder builder) throws IOExc
.endObject();
}

/**
* {@link DataFrameAnalyticsConfig} mapping.
* Does not include mapping for CREATE_TIME as this mapping is added by {@link #addJobConfigFields} method.
*/
public static void addDataFrameAnalyticsFields(XContentBuilder builder) throws IOException {
builder.startObject(DataFrameAnalyticsConfig.ID.getPreferredName())
.field(TYPE, KEYWORD)
Expand Down Expand Up @@ -434,6 +438,10 @@ public static void addDataFrameAnalyticsFields(XContentBuilder builder) throws I
.endObject()
.endObject()
.endObject()
.endObject()
// re-used: CREATE_TIME
.startObject(DataFrameAnalyticsConfig.VERSION.getPreferredName())
.field(TYPE, KEYWORD)
.endObject();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,8 @@ public final class ReservedFieldNames {
DataFrameAnalyticsConfig.DEST.getPreferredName(),
DataFrameAnalyticsConfig.ANALYSIS.getPreferredName(),
DataFrameAnalyticsConfig.ANALYZED_FIELDS.getPreferredName(),
DataFrameAnalyticsConfig.CREATE_TIME.getPreferredName(),
DataFrameAnalyticsConfig.VERSION.getPreferredName(),
DataFrameAnalyticsDest.INDEX.getPreferredName(),
DataFrameAnalyticsDest.RESULTS_FIELD.getPreferredName(),
DataFrameAnalyticsSource.INDEX.getPreferredName(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,19 @@ setup:
- is_true: create_time
- is_true: version

- do:
ml.get_data_frame_analytics:
id: "simple-outlier-detection-with-query"
- match: { count: 1 }
- match: { data_frame_analytics.0.id: "simple-outlier-detection-with-query" }
- match: { data_frame_analytics.0.source.index: "index-source" }
- match: { data_frame_analytics.0.source.query: {"term" : { "user" : "Kimchy"} } }
- match: { data_frame_analytics.0.dest.index: "index-dest" }
- match: { data_frame_analytics.0.analysis: {"outlier_detection":{}} }
- match: { data_frame_analytics.0.analyzed_fields: {"includes" : ["obj1.*", "obj2.*" ], "excludes": [] } }
- is_true: data_frame_analytics.0.create_time
- is_true: data_frame_analytics.0.version

---
"Test put config with security headers in the body":
- do:
Expand Down

0 comments on commit a0d487e

Please sign in to comment.