Skip to content

Commit 366e22d

Browse files
authored
[DOCS] Fix min/max agg snippets for histograms (#83695) (#83701)
* 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 #83384 (cherry picked from commit 280fd2f)
1 parent 92df3c6 commit 366e22d

File tree

2 files changed

+34
-20
lines changed

2 files changed

+34
-20
lines changed

docs/reference/aggregations/metrics/max-aggregation.asciidoc

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,17 @@ of all elements in the `values` array. Note, that the `counts` array of the hist
123123
For example, for the following index that stores pre-aggregated histograms with latency metrics for different networks:
124124

125125
[source,console]
126-
--------------------------------------------------
127-
PUT metrics_index/_doc/1
126+
----
127+
PUT metrics_index
128+
{
129+
"mappings": {
130+
"properties": {
131+
"latency_histo": { "type": "histogram" }
132+
}
133+
}
134+
}
135+
136+
PUT metrics_index/_doc/1?refresh
128137
{
129138
"network.name" : "net-1",
130139
"latency_histo" : {
@@ -133,7 +142,7 @@ PUT metrics_index/_doc/1
133142
}
134143
}
135144
136-
PUT metrics_index/_doc/2
145+
PUT metrics_index/_doc/2?refresh
137146
{
138147
"network.name" : "net-2",
139148
"latency_histo" : {
@@ -142,25 +151,23 @@ PUT metrics_index/_doc/2
142151
}
143152
}
144153
145-
POST /metrics_index/_search?size=0
154+
POST /metrics_index/_search?size=0&filter_path=aggregations
146155
{
147156
"aggs" : {
148-
"min_latency" : { "min" : { "field" : "latency_histo" } }
157+
"max_latency" : { "max" : { "field" : "latency_histo" } }
149158
}
150159
}
151-
--------------------------------------------------
160+
----
152161

153162
The `max` aggregation will return the maximum value of all histogram fields:
154163

155164
[source,console-result]
156-
--------------------------------------------------
165+
----
157166
{
158-
...
159167
"aggregations": {
160-
"min_latency": {
168+
"max_latency": {
161169
"value": 0.5
162170
}
163171
}
164172
}
165-
--------------------------------------------------
166-
// TESTRESPONSE[skip:test not setup]
173+
----

docs/reference/aggregations/metrics/min-aggregation.asciidoc

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,17 @@ of all elements in the `values` array. Note, that the `counts` array of the hist
123123
For example, for the following index that stores pre-aggregated histograms with latency metrics for different networks:
124124

125125
[source,console]
126-
--------------------------------------------------
127-
PUT metrics_index/_doc/1
126+
----
127+
PUT metrics_index
128+
{
129+
"mappings": {
130+
"properties": {
131+
"latency_histo": { "type": "histogram" }
132+
}
133+
}
134+
}
135+
136+
PUT metrics_index/_doc/1?refresh
128137
{
129138
"network.name" : "net-1",
130139
"latency_histo" : {
@@ -133,7 +142,7 @@ PUT metrics_index/_doc/1
133142
}
134143
}
135144
136-
PUT metrics_index/_doc/2
145+
PUT metrics_index/_doc/2?refresh
137146
{
138147
"network.name" : "net-2",
139148
"latency_histo" : {
@@ -142,25 +151,23 @@ PUT metrics_index/_doc/2
142151
}
143152
}
144153
145-
POST /metrics_index/_search?size=0
154+
POST /metrics_index/_search?size=0&filter_path=aggregations
146155
{
147156
"aggs" : {
148157
"min_latency" : { "min" : { "field" : "latency_histo" } }
149158
}
150159
}
151-
--------------------------------------------------
160+
----
152161

153162
The `min` aggregation will return the minimum value of all histogram fields:
154163

155164
[source,console-result]
156-
--------------------------------------------------
165+
----
157166
{
158-
...
159167
"aggregations": {
160168
"min_latency": {
161169
"value": 0.1
162170
}
163171
}
164172
}
165-
--------------------------------------------------
166-
// TESTRESPONSE[skip:test not setup]
173+
----

0 commit comments

Comments
 (0)