Skip to content

Commit

Permalink
[ML] Job and datafeed mappings with index template (#32719)
Browse files Browse the repository at this point in the history
Index mappings for the configuration documents
  • Loading branch information
davidkyle committed Oct 18, 2018
1 parent c666ba0 commit 0fc87c8
Show file tree
Hide file tree
Showing 14 changed files with 513 additions and 60 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ public class DatafeedConfig extends AbstractDiffable<DatafeedConfig> implements

// Used for QueryPage
public static final ParseField RESULTS_FIELD = new ParseField("datafeeds");
public static String TYPE = "datafeed";

/**
* The field name used to specify document counts in Elasticsearch
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,17 @@ public class AnalysisConfig implements ToXContentObject, Writeable {
* Serialisation names
*/
public static final ParseField ANALYSIS_CONFIG = new ParseField("analysis_config");
private static final ParseField BUCKET_SPAN = new ParseField("bucket_span");
private static final ParseField CATEGORIZATION_FIELD_NAME = new ParseField("categorization_field_name");
static final ParseField CATEGORIZATION_FILTERS = new ParseField("categorization_filters");
private static final ParseField CATEGORIZATION_ANALYZER = CategorizationAnalyzerConfig.CATEGORIZATION_ANALYZER;
private static final ParseField LATENCY = new ParseField("latency");
private static final ParseField SUMMARY_COUNT_FIELD_NAME = new ParseField("summary_count_field_name");
private static final ParseField DETECTORS = new ParseField("detectors");
private static final ParseField INFLUENCERS = new ParseField("influencers");
private static final ParseField OVERLAPPING_BUCKETS = new ParseField("overlapping_buckets");
private static final ParseField RESULT_FINALIZATION_WINDOW = new ParseField("result_finalization_window");
private static final ParseField MULTIVARIATE_BY_FIELDS = new ParseField("multivariate_by_fields");
public static final ParseField BUCKET_SPAN = new ParseField("bucket_span");
public static final ParseField CATEGORIZATION_FIELD_NAME = new ParseField("categorization_field_name");
public static final ParseField CATEGORIZATION_FILTERS = new ParseField("categorization_filters");
public static final ParseField CATEGORIZATION_ANALYZER = CategorizationAnalyzerConfig.CATEGORIZATION_ANALYZER;
public static final ParseField LATENCY = new ParseField("latency");
public static final ParseField SUMMARY_COUNT_FIELD_NAME = new ParseField("summary_count_field_name");
public static final ParseField DETECTORS = new ParseField("detectors");
public static final ParseField INFLUENCERS = new ParseField("influencers");
public static final ParseField OVERLAPPING_BUCKETS = new ParseField("overlapping_buckets");
public static final ParseField RESULT_FINALIZATION_WINDOW = new ParseField("result_finalization_window");
public static final ParseField MULTIVARIATE_BY_FIELDS = new ParseField("multivariate_by_fields");

public static final String ML_CATEGORY_FIELD = "mlcategory";
public static final Set<String> AUTO_CREATED_FIELDS = new HashSet<>(Collections.singletonList(ML_CATEGORY_FIELD));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@
public class CategorizationAnalyzerConfig implements ToXContentFragment, Writeable {

public static final ParseField CATEGORIZATION_ANALYZER = new ParseField("categorization_analyzer");
private static final ParseField TOKENIZER = RestAnalyzeAction.Fields.TOKENIZER;
private static final ParseField TOKEN_FILTERS = RestAnalyzeAction.Fields.TOKEN_FILTERS;
private static final ParseField CHAR_FILTERS = RestAnalyzeAction.Fields.CHAR_FILTERS;
public static final ParseField TOKENIZER = RestAnalyzeAction.Fields.TOKENIZER;
public static final ParseField TOKEN_FILTERS = RestAnalyzeAction.Fields.TOKEN_FILTERS;
public static final ParseField CHAR_FILTERS = RestAnalyzeAction.Fields.CHAR_FILTERS;

/**
* This method is only used in the unit tests - in production code this config is always parsed as a fragment.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,12 @@ public String toString() {
}
}

private static final ParseField DATA_DESCRIPTION_FIELD = new ParseField("data_description");
private static final ParseField FORMAT_FIELD = new ParseField("format");
private static final ParseField TIME_FIELD_NAME_FIELD = new ParseField("time_field");
private static final ParseField TIME_FORMAT_FIELD = new ParseField("time_format");
private static final ParseField FIELD_DELIMITER_FIELD = new ParseField("field_delimiter");
private static final ParseField QUOTE_CHARACTER_FIELD = new ParseField("quote_character");
public static final ParseField DATA_DESCRIPTION_FIELD = new ParseField("data_description");
public static final ParseField FORMAT_FIELD = new ParseField("format");
public static final ParseField TIME_FIELD_NAME_FIELD = new ParseField("time_field");
public static final ParseField TIME_FORMAT_FIELD = new ParseField("time_format");
public static final ParseField FIELD_DELIMITER_FIELD = new ParseField("field_delimiter");
public static final ParseField QUOTE_CHARACTER_FIELD = new ParseField("quote_character");

/**
* Special time format string for epoch times (seconds)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@

public class ModelPlotConfig implements ToXContentObject, Writeable {

private static final ParseField TYPE_FIELD = new ParseField("model_plot_config");
private static final ParseField ENABLED_FIELD = new ParseField("enabled");
public static final ParseField TYPE_FIELD = new ParseField("model_plot_config");
public static final ParseField ENABLED_FIELD = new ParseField("enabled");
public static final ParseField TERMS_FIELD = new ParseField("terms");

// These parsers follow the pattern that metadata is parsed leniently (to allow for enhancements), whilst config is parsed strictly
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,14 @@ public static String getPhysicalIndexFromState(ClusterState state, String jobId)
public static String jobStateIndexName() {
return AnomalyDetectorsIndexFields.STATE_INDEX_NAME;
}

/**
* The name of the index where job and datafeed configuration
* is stored
* @return The index name
*/
public static String configIndexName() {
return AnomalyDetectorsIndexFields.CONFIG_INDEX;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

public final class AnomalyDetectorsIndexFields {

public static final String CONFIG_INDEX = ".ml-config";
public static final String RESULTS_INDEX_PREFIX = ".ml-anomalies-";
public static final String STATE_INDEX_NAME = ".ml-state";
public static final String RESULTS_INDEX_DEFAULT = "shared";
Expand Down
Loading

0 comments on commit 0fc87c8

Please sign in to comment.