Skip to content

[DOCS] Fix min/max agg snippets for histograms #83695

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 18 additions & 11 deletions docs/reference/aggregations/metrics/max-aggregation.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -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" : {
Expand All @@ -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" : {
Expand All @@ -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]
----
25 changes: 16 additions & 9 deletions docs/reference/aggregations/metrics/min-aggregation.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -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" : {
Expand All @@ -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" : {
Expand All @@ -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]
----