Skip to content

Commit 7b111e8

Browse files
[ML] Improve error for functions with limited rule condition support (#32548)
Closes #32545
1 parent c2fff29 commit 7b111e8

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

x-pack/docs/en/rest-api/ml/jobresource.asciidoc

+1-1
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ A rule has the following properties:
455455
+
456456
--
457457
NOTE: If your detector uses `lat_long`, `metric`, `rare`, or `freq_rare`
458-
functions, you cannot specify `conditions` for your rule.
458+
functions, you can only specify `conditions` that apply to `time`.
459459

460460

461461
A condition has the following properties:

x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/messages/Messages.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ public final class Messages {
9292
public static final String JOB_CONFIG_CATEGORIZATION_ANALYZER_REQUIRES_CATEGORIZATION_FIELD_NAME =
9393
"categorization_analyzer requires setting categorization_field_name";
9494
public static final String JOB_CONFIG_DETECTION_RULE_NOT_SUPPORTED_BY_FUNCTION =
95-
"Invalid detector rule: function {0} does not support rules with conditions";
95+
"Invalid detector rule: function {0} only supports conditions that apply to time";
9696
public static final String JOB_CONFIG_DETECTION_RULE_REQUIRES_SCOPE_OR_CONDITION =
9797
"Invalid detector rule: at least scope or a condition is required";
9898
public static final String JOB_CONFIG_DETECTION_RULE_SCOPE_HAS_INVALID_FIELD =

x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/job/config/DetectorTests.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,7 @@ public void testVerify_GivenRulesAndFunctionIsLatLong() {
541541

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

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

547547
public void testVerify_GivenRulesAndFunctionIsMetric() {
@@ -551,7 +551,7 @@ public void testVerify_GivenRulesAndFunctionIsMetric() {
551551

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

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

557557
public void testVerify_GivenRulesAndFunctionIsRare() {
@@ -562,7 +562,7 @@ public void testVerify_GivenRulesAndFunctionIsRare() {
562562

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

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

568568
public void testVerify_GivenRulesAndFunctionIsFreqRare() {
@@ -574,7 +574,7 @@ public void testVerify_GivenRulesAndFunctionIsFreqRare() {
574574

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

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

580580
public void testVerify_GivenTimeConditionRuleAndFunctionIsLatLong() {

0 commit comments

Comments
 (0)