@@ -102,6 +102,7 @@ Verify this response as well but in a hidden block.
102
102
103
103
For more details on specifying scripts see <<modules-scripting, script documentation>>.
104
104
105
+ [[_allowed_return_types]]
105
106
==== Allowed return types
106
107
107
108
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
111
112
* Map (containing only keys and values of the types listed here)
112
113
* Array (containing elements of only the types listed here)
113
114
115
+ [[_scope_of_scripts]]
114
116
==== Scope of scripts
115
117
116
118
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
139
141
In the above example, the `reduce_script` iterates through the `profit` returned by each shard summing the values before returning the
140
142
final combined profit which will be returned in the response of the aggregation.
141
143
142
- ==== Worked Example
144
+ [[_worked_example]]
145
+ ==== Worked example
143
146
144
147
Imagine a situation where you index the following documents into an index with 2 shards:
145
148
@@ -255,7 +258,8 @@ produce the response:
255
258
--------------------------------------------------
256
259
// NOTCONSOLE
257
260
258
- ==== Other Parameters
261
+ [[_other_parameters]]
262
+ ==== Other parameters
259
263
260
264
[horizontal]
261
265
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
268
272
--------------------------------------------------
269
273
// NOTCONSOLE
270
274
271
- ==== Empty Buckets
275
+ [[_empty_buckets]]
276
+ ==== Empty buckets
272
277
273
278
If a parent bucket of the scripted metric aggregation does not collect any documents an empty aggregation response will be returned from the
274
279
shard with a `null` value. In this case the `reduce_script`'s `states` variable will contain `null` as a response from that shard.
0 commit comments