Skip to content

Commit 965ae24

Browse files
authored
[ML] Job and datafeed mappings with index template (#32719)
Index mappings for the configuration documents
1 parent 027a22a commit 965ae24

File tree

15 files changed

+518
-64
lines changed

15 files changed

+518
-64
lines changed

x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/datafeed/DatafeedConfig.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ public class DatafeedConfig extends AbstractDiffable<DatafeedConfig> implements
6262

6363
// Used for QueryPage
6464
public static final ParseField RESULTS_FIELD = new ParseField("datafeeds");
65+
public static String TYPE = "datafeed";
6566

6667
/**
6768
* The field name used to specify document counts in Elasticsearch

x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/config/AnalysisConfig.java

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -53,18 +53,19 @@ public class AnalysisConfig implements ToXContentObject, Writeable {
5353
* Serialisation names
5454
*/
5555
public static final ParseField ANALYSIS_CONFIG = new ParseField("analysis_config");
56-
private static final ParseField BUCKET_SPAN = new ParseField("bucket_span");
57-
private static final ParseField CATEGORIZATION_FIELD_NAME = new ParseField("categorization_field_name");
58-
static final ParseField CATEGORIZATION_FILTERS = new ParseField("categorization_filters");
59-
private static final ParseField CATEGORIZATION_ANALYZER = CategorizationAnalyzerConfig.CATEGORIZATION_ANALYZER;
60-
private static final ParseField LATENCY = new ParseField("latency");
61-
private static final ParseField SUMMARY_COUNT_FIELD_NAME = new ParseField("summary_count_field_name");
62-
private static final ParseField DETECTORS = new ParseField("detectors");
63-
private static final ParseField INFLUENCERS = new ParseField("influencers");
64-
private static final ParseField OVERLAPPING_BUCKETS = new ParseField("overlapping_buckets");
65-
private static final ParseField RESULT_FINALIZATION_WINDOW = new ParseField("result_finalization_window");
66-
private static final ParseField MULTIVARIATE_BY_FIELDS = new ParseField("multivariate_by_fields");
67-
private static final ParseField USER_PER_PARTITION_NORMALIZATION = new ParseField("use_per_partition_normalization");
56+
57+
public static final ParseField BUCKET_SPAN = new ParseField("bucket_span");
58+
public static final ParseField CATEGORIZATION_FIELD_NAME = new ParseField("categorization_field_name");
59+
public static final ParseField CATEGORIZATION_FILTERS = new ParseField("categorization_filters");
60+
public static final ParseField CATEGORIZATION_ANALYZER = CategorizationAnalyzerConfig.CATEGORIZATION_ANALYZER;
61+
public static final ParseField LATENCY = new ParseField("latency");
62+
public static final ParseField SUMMARY_COUNT_FIELD_NAME = new ParseField("summary_count_field_name");
63+
public static final ParseField DETECTORS = new ParseField("detectors");
64+
public static final ParseField INFLUENCERS = new ParseField("influencers");
65+
public static final ParseField OVERLAPPING_BUCKETS = new ParseField("overlapping_buckets");
66+
public static final ParseField RESULT_FINALIZATION_WINDOW = new ParseField("result_finalization_window");
67+
public static final ParseField MULTIVARIATE_BY_FIELDS = new ParseField("multivariate_by_fields");
68+
public static final ParseField USE_PER_PARTITION_NORMALIZATION = new ParseField("use_per_partition_normalization");
6869

6970
public static final String ML_CATEGORY_FIELD = "mlcategory";
7071
public static final Set<String> AUTO_CREATED_FIELDS = new HashSet<>(Collections.singletonList(ML_CATEGORY_FIELD));
@@ -98,7 +99,7 @@ private static ConstructingObjectParser<AnalysisConfig.Builder, Void> createPars
9899
parser.declareBoolean(Builder::setOverlappingBuckets, OVERLAPPING_BUCKETS);
99100
parser.declareLong(Builder::setResultFinalizationWindow, RESULT_FINALIZATION_WINDOW);
100101
parser.declareBoolean(Builder::setMultivariateByFields, MULTIVARIATE_BY_FIELDS);
101-
parser.declareBoolean(Builder::setUsePerPartitionNormalization, USER_PER_PARTITION_NORMALIZATION);
102+
parser.declareBoolean(Builder::setUsePerPartitionNormalization, USE_PER_PARTITION_NORMALIZATION);
102103

103104
return parser;
104105
}
@@ -404,7 +405,7 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
404405
builder.field(MULTIVARIATE_BY_FIELDS.getPreferredName(), multivariateByFields);
405406
}
406407
if (usePerPartitionNormalization) {
407-
builder.field(USER_PER_PARTITION_NORMALIZATION.getPreferredName(), usePerPartitionNormalization);
408+
builder.field(USE_PER_PARTITION_NORMALIZATION.getPreferredName(), usePerPartitionNormalization);
408409
}
409410
builder.endObject();
410411
return builder;

x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/config/CategorizationAnalyzerConfig.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@
5353
public class CategorizationAnalyzerConfig implements ToXContentFragment, Writeable {
5454

5555
public static final ParseField CATEGORIZATION_ANALYZER = new ParseField("categorization_analyzer");
56-
private static final ParseField TOKENIZER = RestAnalyzeAction.Fields.TOKENIZER;
57-
private static final ParseField TOKEN_FILTERS = RestAnalyzeAction.Fields.TOKEN_FILTERS;
58-
private static final ParseField CHAR_FILTERS = RestAnalyzeAction.Fields.CHAR_FILTERS;
56+
public static final ParseField TOKENIZER = RestAnalyzeAction.Fields.TOKENIZER;
57+
public static final ParseField TOKEN_FILTERS = RestAnalyzeAction.Fields.TOKEN_FILTERS;
58+
public static final ParseField CHAR_FILTERS = RestAnalyzeAction.Fields.CHAR_FILTERS;
5959

6060
/**
6161
* This method is only used in the unit tests - in production code this config is always parsed as a fragment.

x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/config/DataDescription.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,12 @@ public String toString() {
7777
}
7878
}
7979

80-
private static final ParseField DATA_DESCRIPTION_FIELD = new ParseField("data_description");
81-
private static final ParseField FORMAT_FIELD = new ParseField("format");
82-
private static final ParseField TIME_FIELD_NAME_FIELD = new ParseField("time_field");
83-
private static final ParseField TIME_FORMAT_FIELD = new ParseField("time_format");
84-
private static final ParseField FIELD_DELIMITER_FIELD = new ParseField("field_delimiter");
85-
private static final ParseField QUOTE_CHARACTER_FIELD = new ParseField("quote_character");
80+
public static final ParseField DATA_DESCRIPTION_FIELD = new ParseField("data_description");
81+
public static final ParseField FORMAT_FIELD = new ParseField("format");
82+
public static final ParseField TIME_FIELD_NAME_FIELD = new ParseField("time_field");
83+
public static final ParseField TIME_FORMAT_FIELD = new ParseField("time_format");
84+
public static final ParseField FIELD_DELIMITER_FIELD = new ParseField("field_delimiter");
85+
public static final ParseField QUOTE_CHARACTER_FIELD = new ParseField("quote_character");
8686

8787
/**
8888
* Special time format string for epoch times (seconds)

x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/config/ModelPlotConfig.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818

1919
public class ModelPlotConfig implements ToXContentObject, Writeable {
2020

21-
private static final ParseField TYPE_FIELD = new ParseField("model_plot_config");
22-
private static final ParseField ENABLED_FIELD = new ParseField("enabled");
21+
public static final ParseField TYPE_FIELD = new ParseField("model_plot_config");
22+
public static final ParseField ENABLED_FIELD = new ParseField("enabled");
2323
public static final ParseField TERMS_FIELD = new ParseField("terms");
2424

2525
// These parsers follow the pattern that metadata is parsed leniently (to allow for enhancements), whilst config is parsed strictly

x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/persistence/AnomalyDetectorsIndex.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,4 +56,14 @@ public static String getPhysicalIndexFromState(ClusterState state, String jobId)
5656
public static String jobStateIndexName() {
5757
return AnomalyDetectorsIndexFields.STATE_INDEX_NAME;
5858
}
59+
60+
/**
61+
* The name of the index where job and datafeed configuration
62+
* is stored
63+
* @return The index name
64+
*/
65+
public static String configIndexName() {
66+
return AnomalyDetectorsIndexFields.CONFIG_INDEX;
67+
}
68+
5969
}

x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/persistence/AnomalyDetectorsIndexFields.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
public final class AnomalyDetectorsIndexFields {
99

10+
public static final String CONFIG_INDEX = ".ml-config";
1011
public static final String RESULTS_INDEX_PREFIX = ".ml-anomalies-";
1112
public static final String STATE_INDEX_NAME = ".ml-state";
1213
public static final String RESULTS_INDEX_DEFAULT = "shared";

0 commit comments

Comments
 (0)