From 3da4cc65b35168d6b72c66fb5b9dfb16eb9029e4 Mon Sep 17 00:00:00 2001 From: James Rodewig Date: Tue, 8 Feb 2022 19:48:15 -0500 Subject: [PATCH] [DOCS] Fix min/max agg snippets for histograms (#83695) * Updates the `min` and `max` snippets for histograms. These should now run as docs integration tests. * Fixes a copy/paste error in the `max` aggregation snippet for histograms. Relates to https://github.com/elastic/elasticsearch/pull/83384 (cherry picked from commit 280fd2fff75a1cc3e5116e7d6c46b487ad597d25) --- .../metrics/max-aggregation.asciidoc | 29 ++++++++++++------- .../metrics/min-aggregation.asciidoc | 25 ++++++++++------ 2 files changed, 34 insertions(+), 20 deletions(-) diff --git a/docs/reference/aggregations/metrics/max-aggregation.asciidoc b/docs/reference/aggregations/metrics/max-aggregation.asciidoc index b5a34fd3f9b2b..2435f800bb6da 100644 --- a/docs/reference/aggregations/metrics/max-aggregation.asciidoc +++ b/docs/reference/aggregations/metrics/max-aggregation.asciidoc @@ -123,8 +123,17 @@ of all elements in the `values` array. Note, that the `counts` array of the hist For example, for the following index that stores pre-aggregated histograms with latency metrics for different networks: [source,console] --------------------------------------------------- -PUT metrics_index/_doc/1 +---- +PUT metrics_index +{ + "mappings": { + "properties": { + "latency_histo": { "type": "histogram" } + } + } +} + +PUT metrics_index/_doc/1?refresh { "network.name" : "net-1", "latency_histo" : { @@ -133,7 +142,7 @@ PUT metrics_index/_doc/1 } } -PUT metrics_index/_doc/2 +PUT metrics_index/_doc/2?refresh { "network.name" : "net-2", "latency_histo" : { @@ -142,25 +151,23 @@ PUT metrics_index/_doc/2 } } -POST /metrics_index/_search?size=0 +POST /metrics_index/_search?size=0&filter_path=aggregations { "aggs" : { - "min_latency" : { "min" : { "field" : "latency_histo" } } + "max_latency" : { "max" : { "field" : "latency_histo" } } } } --------------------------------------------------- +---- The `max` aggregation will return the maximum value of all histogram fields: [source,console-result] --------------------------------------------------- +---- { - ... "aggregations": { - "min_latency": { + "max_latency": { "value": 0.5 } } } --------------------------------------------------- -// TESTRESPONSE[skip:test not setup] +---- diff --git a/docs/reference/aggregations/metrics/min-aggregation.asciidoc b/docs/reference/aggregations/metrics/min-aggregation.asciidoc index 04a5fb42afe03..d4c3135cc576e 100644 --- a/docs/reference/aggregations/metrics/min-aggregation.asciidoc +++ b/docs/reference/aggregations/metrics/min-aggregation.asciidoc @@ -123,8 +123,17 @@ of all elements in the `values` array. Note, that the `counts` array of the hist For example, for the following index that stores pre-aggregated histograms with latency metrics for different networks: [source,console] --------------------------------------------------- -PUT metrics_index/_doc/1 +---- +PUT metrics_index +{ + "mappings": { + "properties": { + "latency_histo": { "type": "histogram" } + } + } +} + +PUT metrics_index/_doc/1?refresh { "network.name" : "net-1", "latency_histo" : { @@ -133,7 +142,7 @@ PUT metrics_index/_doc/1 } } -PUT metrics_index/_doc/2 +PUT metrics_index/_doc/2?refresh { "network.name" : "net-2", "latency_histo" : { @@ -142,25 +151,23 @@ PUT metrics_index/_doc/2 } } -POST /metrics_index/_search?size=0 +POST /metrics_index/_search?size=0&filter_path=aggregations { "aggs" : { "min_latency" : { "min" : { "field" : "latency_histo" } } } } --------------------------------------------------- +---- The `min` aggregation will return the minimum value of all histogram fields: [source,console-result] --------------------------------------------------- +---- { - ... "aggregations": { "min_latency": { "value": 0.1 } } } --------------------------------------------------- -// TESTRESPONSE[skip:test not setup] +----