Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Aggregations: Fixed Histogram key_as_string bug
The key as string field in the response for the histogram aggregation will now only show if format is specified on the request. Closes #6655
- Loading branch information
Showing
2 changed files
with
130 additions
and
1 deletion.
There are no files selected for viewing
129 changes: 129 additions & 0 deletions
129
rest-api-spec/test/search.aggregation/10_histogram.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
--- | ||
"Basic test": | ||
- do: | ||
index: | ||
index: test_1 | ||
type: test | ||
id: 1 | ||
body: { "number" : 1 } | ||
|
||
- do: | ||
index: | ||
index: test_1 | ||
type: test | ||
id: 2 | ||
body: { "number" : 51 } | ||
|
||
- do: | ||
index: | ||
index: test_1 | ||
type: test | ||
id: 3 | ||
body: { "number" : 101 } | ||
|
||
- do: | ||
index: | ||
index: test_1 | ||
type: test | ||
id: 4 | ||
body: { "number" : 151 } | ||
|
||
- do: | ||
indices.refresh: {} | ||
|
||
- do: | ||
search: | ||
body: { "aggs" : { "histo" : { "histogram" : { "field" : "number", "interval" : 50 } } } } | ||
|
||
- match: { hits.total: 4 } | ||
|
||
- length: { aggregations.histo.buckets: 4 } | ||
|
||
- match: { aggregations.histo.buckets.0.key: 0 } | ||
|
||
- is_false: aggregations.histo.buckets.0.key_as_string | ||
|
||
- match: { aggregations.histo.buckets.0.doc_count: 1 } | ||
|
||
- match: { aggregations.histo.buckets.1.key: 50 } | ||
|
||
- is_false: aggregations.histo.buckets.1.key_as_string | ||
|
||
- match: { aggregations.histo.buckets.1.doc_count: 1 } | ||
|
||
- match: { aggregations.histo.buckets.2.key: 100 } | ||
|
||
- is_false: aggregations.histo.buckets.2.key_as_string | ||
|
||
- match: { aggregations.histo.buckets.2.doc_count: 1 } | ||
|
||
- match: { aggregations.histo.buckets.3.key: 150 } | ||
|
||
- is_false: aggregations.histo.buckets.3.key_as_string | ||
|
||
- match: { aggregations.histo.buckets.3.doc_count: 1 } | ||
|
||
--- | ||
"Format test": | ||
- do: | ||
index: | ||
index: test_1 | ||
type: test | ||
id: 1 | ||
body: { "number" : 1 } | ||
|
||
- do: | ||
index: | ||
index: test_1 | ||
type: test | ||
id: 2 | ||
body: { "number" : 51 } | ||
|
||
- do: | ||
index: | ||
index: test_1 | ||
type: test | ||
id: 3 | ||
body: { "number" : 101 } | ||
|
||
- do: | ||
index: | ||
index: test_1 | ||
type: test | ||
id: 4 | ||
body: { "number" : 151 } | ||
|
||
- do: | ||
indices.refresh: {} | ||
|
||
- do: | ||
search: | ||
body: { "aggs" : { "histo" : { "histogram" : { "field" : "number", "interval" : 50, "format" : "Value is ##0.0" } } } } | ||
|
||
- match: { hits.total: 4 } | ||
|
||
- length: { aggregations.histo.buckets: 4 } | ||
|
||
- match: { aggregations.histo.buckets.0.key: 0 } | ||
|
||
- match: { aggregations.histo.buckets.0.key_as_string: "Value is 0.0" } | ||
|
||
- match: { aggregations.histo.buckets.0.doc_count: 1 } | ||
|
||
- match: { aggregations.histo.buckets.1.key: 50 } | ||
|
||
- match: { aggregations.histo.buckets.1.key_as_string: "Value is 50.0" } | ||
|
||
- match: { aggregations.histo.buckets.1.doc_count: 1 } | ||
|
||
- match: { aggregations.histo.buckets.2.key: 100 } | ||
|
||
- match: { aggregations.histo.buckets.2.key_as_string: "Value is 100.0" } | ||
|
||
- match: { aggregations.histo.buckets.2.doc_count: 1 } | ||
|
||
- match: { aggregations.histo.buckets.3.key: 150 } | ||
|
||
- match: { aggregations.histo.buckets.3.key_as_string: "Value is 150.0" } | ||
|
||
- match: { aggregations.histo.buckets.3.doc_count: 1 } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters