From fb2b0f1d3b5998aef738cc9b297275c467bb294a Mon Sep 17 00:00:00 2001 From: Benjamin Trent Date: Tue, 15 Jun 2021 11:44:54 -0400 Subject: [PATCH 1/2] Fix mapping error to indicate values field (#74132) The error message erroneously mentions the count field being out of order. It should instead mention the values field --- .../xpack/analytics/mapper/HistogramFieldMapper.java | 2 +- .../resources/rest-api-spec/test/analytics/histogram.yml | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/x-pack/plugin/analytics/src/main/java/org/elasticsearch/xpack/analytics/mapper/HistogramFieldMapper.java b/x-pack/plugin/analytics/src/main/java/org/elasticsearch/xpack/analytics/mapper/HistogramFieldMapper.java index 03ce9920f33c3..fcb9af599300e 100644 --- a/x-pack/plugin/analytics/src/main/java/org/elasticsearch/xpack/analytics/mapper/HistogramFieldMapper.java +++ b/x-pack/plugin/analytics/src/main/java/org/elasticsearch/xpack/analytics/mapper/HistogramFieldMapper.java @@ -260,7 +260,7 @@ public void parse(ParseContext context) throws IOException { if (val < previousVal) { // values must be in increasing order throw new MapperParsingException("error parsing field [" - + name() + "], ["+ COUNTS_FIELD + "] values must be in increasing order, got [" + val + + + name() + "], ["+ VALUES_FIELD + "] values must be in increasing order, got [" + val + "] but previous value was [" + previousVal +"]"); } values.add(val); diff --git a/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/analytics/histogram.yml b/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/analytics/histogram.yml index 2cf0196154078..dd07ef66f58cb 100644 --- a/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/analytics/histogram.yml +++ b/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/analytics/histogram.yml @@ -20,7 +20,13 @@ setup: - '{"latency": {"values" : [0.1, 0.2, 0.3, 0.4, 0.5], "counts" : [3, 7, 23, 12, 6]}}' - '{"index": {}}' - '{"latency": {"values" : [0, 0.1, 0.2, 0.3, 0.4, 0.5], "counts" : [3, 2, 5, 10, 1, 8]}}' - +--- +"Histogram requires values in increasing order": + - do: + catch: / error parsing field \[latency\], \[values\] values must be in increasing order, got \[0.2\] but previous value was \[1.0\]/ + index: + index: test + body: {"latency": {"values" : [1.0, 0.2, 0.3, 0.4, 0.5], "counts" : [3, 7, 23, 12, 6]}} --- "Histogram Aggregations": From e795c86890b2df9df97faab8ae5e4c54e02953d7 Mon Sep 17 00:00:00 2001 From: Benjamin Trent <4357155+benwtrent@users.noreply.github.com> Date: Tue, 15 Jun 2021 12:22:51 -0400 Subject: [PATCH 2/2] fixing regex --- .../resources/rest-api-spec/test/analytics/histogram.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/analytics/histogram.yml b/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/analytics/histogram.yml index dd07ef66f58cb..0f35449fce61e 100644 --- a/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/analytics/histogram.yml +++ b/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/analytics/histogram.yml @@ -23,7 +23,7 @@ setup: --- "Histogram requires values in increasing order": - do: - catch: / error parsing field \[latency\], \[values\] values must be in increasing order, got \[0.2\] but previous value was \[1.0\]/ + catch: /error parsing field \[latency\], \[values\] values must be in increasing order/ index: index: test body: {"latency": {"values" : [1.0, 0.2, 0.3, 0.4, 0.5], "counts" : [3, 7, 23, 12, 6]}}