Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ML] Improve error for functions with limited rule condition support #32548

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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