Skip to content

Commit 1de7a4a

Browse files
authored
[7.x] Fix mapping error to indicate values field (#74132) (#74137)
* 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
1 parent 16d2142 commit 1de7a4a

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

x-pack/plugin/analytics/src/main/java/org/elasticsearch/xpack/analytics/mapper/HistogramFieldMapper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ public void parse(ParseContext context) throws IOException {
260260
if (val < previousVal) {
261261
// values must be in increasing order
262262
throw new MapperParsingException("error parsing field ["
263-
+ name() + "], ["+ COUNTS_FIELD + "] values must be in increasing order, got [" + val +
263+
+ name() + "], ["+ VALUES_FIELD + "] values must be in increasing order, got [" + val +
264264
"] but previous value was [" + previousVal +"]");
265265
}
266266
values.add(val);

x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/analytics/histogram.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,13 @@ setup:
2020
- '{"latency": {"values" : [0.1, 0.2, 0.3, 0.4, 0.5], "counts" : [3, 7, 23, 12, 6]}}'
2121
- '{"index": {}}'
2222
- '{"latency": {"values" : [0, 0.1, 0.2, 0.3, 0.4, 0.5], "counts" : [3, 2, 5, 10, 1, 8]}}'
23-
23+
---
24+
"Histogram requires values in increasing order":
25+
- do:
26+
catch: /error parsing field \[latency\], \[values\] values must be in increasing order/
27+
index:
28+
index: test
29+
body: {"latency": {"values" : [1.0, 0.2, 0.3, 0.4, 0.5], "counts" : [3, 7, 23, 12, 6]}}
2430
---
2531
"Histogram Aggregations":
2632

0 commit comments

Comments
 (0)