From 5310feaefd6659b46c1ec56f3dff28aa3f1fae90 Mon Sep 17 00:00:00 2001 From: Lisa Cawley Date: Mon, 16 Mar 2020 10:17:38 -0700 Subject: [PATCH 1/2] [DOCS] Add anchors for scripted metric aggregations Related to https://github.com/elastic/elasticsearch/pull/53274 This PR adds anchors to sections in https://www.elastic.co/guide/en/elasticsearch/reference/master/search-aggregations-metrics-scripted-metric-aggregation.html so that they can be linked from other pages. --- .../metrics/scripted-metric-aggregation.asciidoc | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/docs/reference/aggregations/metrics/scripted-metric-aggregation.asciidoc b/docs/reference/aggregations/metrics/scripted-metric-aggregation.asciidoc index f73dec1eb8be4..d48996a10f01a 100644 --- a/docs/reference/aggregations/metrics/scripted-metric-aggregation.asciidoc +++ b/docs/reference/aggregations/metrics/scripted-metric-aggregation.asciidoc @@ -102,6 +102,7 @@ Verify this response as well but in a hidden block. For more details on specifying scripts see <>. +[[_allowed_return_types]] ==== Allowed return types Whilst any valid script object can be used within a single script, the scripts must return or store in the `state` object only the following types: @@ -111,6 +112,7 @@ Whilst any valid script object can be used within a single script, the scripts m * Map (containing only keys and values of the types listed here) * Array (containing elements of only the types listed here) +[[_scope_of_scripts]] ==== Scope of scripts The scripted metric aggregation uses scripts at 4 stages of its execution: @@ -139,7 +141,8 @@ reduce_script:: Executed once on the coordinating node after all shards have In the above example, the `reduce_script` iterates through the `profit` returned by each shard summing the values before returning the final combined profit which will be returned in the response of the aggregation. -==== Worked Example +[[_worked_example]] +==== Worked example Imagine a situation where you index the following documents into an index with 2 shards: @@ -255,7 +258,8 @@ produce the response: -------------------------------------------------- // NOTCONSOLE -==== Other Parameters +[[_other_parameters]] +==== Other parameters [horizontal] params:: Optional. An object whose contents will be passed as variables to the `init_script`, `map_script` and `combine_script`. This can be @@ -268,7 +272,8 @@ params:: Optional. An object whose contents will be passed as variable -------------------------------------------------- // NOTCONSOLE -==== Empty Buckets +[[_empty_buckets]] +==== Empty buckets If a parent bucket of the scripted metric aggregation does not collect any documents an empty aggregation response will be returned from the shard with a `null` value. In this case the `reduce_script`'s `states` variable will contain `null` as a response from that shard. From dc2e345965f829d0d532d49f67b029fc9f8b906c Mon Sep 17 00:00:00 2001 From: lcawl Date: Mon, 16 Mar 2020 10:49:10 -0700 Subject: [PATCH 2/2] [DOCS] Improves anchor names --- .../metrics/scripted-metric-aggregation.asciidoc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/reference/aggregations/metrics/scripted-metric-aggregation.asciidoc b/docs/reference/aggregations/metrics/scripted-metric-aggregation.asciidoc index d48996a10f01a..1f753be25d172 100644 --- a/docs/reference/aggregations/metrics/scripted-metric-aggregation.asciidoc +++ b/docs/reference/aggregations/metrics/scripted-metric-aggregation.asciidoc @@ -102,7 +102,7 @@ Verify this response as well but in a hidden block. For more details on specifying scripts see <>. -[[_allowed_return_types]] +[[scripted-metric-aggregation-return-types]] ==== Allowed return types Whilst any valid script object can be used within a single script, the scripts must return or store in the `state` object only the following types: @@ -112,7 +112,7 @@ Whilst any valid script object can be used within a single script, the scripts m * Map (containing only keys and values of the types listed here) * Array (containing elements of only the types listed here) -[[_scope_of_scripts]] +[[scripted-metric-aggregation-scope]] ==== Scope of scripts The scripted metric aggregation uses scripts at 4 stages of its execution: @@ -141,7 +141,7 @@ reduce_script:: Executed once on the coordinating node after all shards have In the above example, the `reduce_script` iterates through the `profit` returned by each shard summing the values before returning the final combined profit which will be returned in the response of the aggregation. -[[_worked_example]] +[[scripted-metric-aggregation-example]] ==== Worked example Imagine a situation where you index the following documents into an index with 2 shards: @@ -258,7 +258,7 @@ produce the response: -------------------------------------------------- // NOTCONSOLE -[[_other_parameters]] +[[scripted-metric-aggregation-parameters]] ==== Other parameters [horizontal] @@ -272,7 +272,7 @@ params:: Optional. An object whose contents will be passed as variable -------------------------------------------------- // NOTCONSOLE -[[_empty_buckets]] +[[scripted-metric-aggregation-empty-buckets]] ==== Empty buckets If a parent bucket of the scripted metric aggregation does not collect any documents an empty aggregation response will be returned from the