From c5140170f7978a3072a635ce0e89be006807726c Mon Sep 17 00:00:00 2001 From: Dimitris Athanasiou Date: Wed, 1 Aug 2018 18:15:46 +0100 Subject: [PATCH] [ML] Improve error for functions with limited rule condition support (#32548) Closes #32545 --- x-pack/docs/en/rest-api/ml/jobresource.asciidoc | 2 +- .../xpack/core/ml/job/messages/Messages.java | 2 +- .../xpack/core/ml/job/config/DetectorTests.java | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/x-pack/docs/en/rest-api/ml/jobresource.asciidoc b/x-pack/docs/en/rest-api/ml/jobresource.asciidoc index e2d35082fb84a..7cccbb83ac029 100644 --- a/x-pack/docs/en/rest-api/ml/jobresource.asciidoc +++ b/x-pack/docs/en/rest-api/ml/jobresource.asciidoc @@ -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: diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/messages/Messages.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/messages/Messages.java index 259d2d06a9c6e..78030c16cedd2 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/messages/Messages.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/messages/Messages.java @@ -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 = diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/job/config/DetectorTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/job/config/DetectorTests.java index 762d1d7ec3931..2f7eab0e97c70 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/job/config/DetectorTests.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/job/config/DetectorTests.java @@ -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() { @@ -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() { @@ -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() { @@ -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() {