Skip to content

Commit

Permalink
[ML] Improve error for functions with limited rule condition support (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
dimitris-athanasiou committed Aug 1, 2018
1 parent c2fff29 commit 7b111e8
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion x-pack/docs/en/rest-api/ml/jobresource.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ A rule has the following properties:
+
--
NOTE: If your detector uses `lat_long`, `metric`, `rare`, or `freq_rare`
functions, you cannot specify `conditions` for your rule.
functions, you can only specify `conditions` that apply to `time`.


A condition has the following properties:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public final class Messages {
public static final String JOB_CONFIG_CATEGORIZATION_ANALYZER_REQUIRES_CATEGORIZATION_FIELD_NAME =
"categorization_analyzer requires setting categorization_field_name";
public static final String JOB_CONFIG_DETECTION_RULE_NOT_SUPPORTED_BY_FUNCTION =
"Invalid detector rule: function {0} does not support rules with conditions";
"Invalid detector rule: function {0} only supports conditions that apply to time";
public static final String JOB_CONFIG_DETECTION_RULE_REQUIRES_SCOPE_OR_CONDITION =
"Invalid detector rule: at least scope or a condition is required";
public static final String JOB_CONFIG_DETECTION_RULE_SCOPE_HAS_INVALID_FIELD =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,7 @@ public void testVerify_GivenRulesAndFunctionIsLatLong() {

ElasticsearchException e = ESTestCase.expectThrows(ElasticsearchException.class, detector::build);

assertThat(e.getMessage(), equalTo("Invalid detector rule: function lat_long does not support rules with conditions"));
assertThat(e.getMessage(), equalTo("Invalid detector rule: function lat_long only supports conditions that apply to time"));
}

public void testVerify_GivenRulesAndFunctionIsMetric() {
Expand All @@ -551,7 +551,7 @@ public void testVerify_GivenRulesAndFunctionIsMetric() {

ElasticsearchException e = ESTestCase.expectThrows(ElasticsearchException.class, detector::build);

assertThat(e.getMessage(), equalTo("Invalid detector rule: function metric does not support rules with conditions"));
assertThat(e.getMessage(), equalTo("Invalid detector rule: function metric only supports conditions that apply to time"));
}

public void testVerify_GivenRulesAndFunctionIsRare() {
Expand All @@ -562,7 +562,7 @@ public void testVerify_GivenRulesAndFunctionIsRare() {

ElasticsearchException e = ESTestCase.expectThrows(ElasticsearchException.class, detector::build);

assertThat(e.getMessage(), equalTo("Invalid detector rule: function rare does not support rules with conditions"));
assertThat(e.getMessage(), equalTo("Invalid detector rule: function rare only supports conditions that apply to time"));
}

public void testVerify_GivenRulesAndFunctionIsFreqRare() {
Expand All @@ -574,7 +574,7 @@ public void testVerify_GivenRulesAndFunctionIsFreqRare() {

ElasticsearchException e = ESTestCase.expectThrows(ElasticsearchException.class, detector::build);

assertThat(e.getMessage(), equalTo("Invalid detector rule: function freq_rare does not support rules with conditions"));
assertThat(e.getMessage(), equalTo("Invalid detector rule: function freq_rare only supports conditions that apply to time"));
}

public void testVerify_GivenTimeConditionRuleAndFunctionIsLatLong() {
Expand Down

0 comments on commit 7b111e8

Please sign in to comment.