2018-07-02 17:44:36 -04:00
|
|
|
[[painless-metric-agg-map-context]]
|
|
|
|
=== Metric aggregation map context
|
|
|
|
|
|
|
|
Use a Painless script to
|
2018-07-25 13:59:25 -04:00
|
|
|
{ref}/search-aggregations-metrics-scripted-metric-aggregation.html[map]
|
2018-07-02 17:44:36 -04:00
|
|
|
values for use in a scripted metric aggregation. A map script is run once per
|
|
|
|
collected document following an optional
|
|
|
|
<<painless-metric-agg-init-context, initialization script>> and is required as
|
|
|
|
part of a full metric aggregation.
|
|
|
|
|
|
|
|
*Variables*
|
|
|
|
|
|
|
|
`params` (`Map`, read-only)::
|
|
|
|
User-defined parameters passed in as part of the query.
|
|
|
|
|
2018-08-10 13:21:54 -04:00
|
|
|
`state` (`Map`)::
|
2018-07-02 17:44:36 -04:00
|
|
|
`Map` used to add values for processing in a
|
2018-08-10 13:21:54 -04:00
|
|
|
<<painless-metric-agg-map-context, combine script>> or to be returned from the aggregation.
|
2018-07-02 17:44:36 -04:00
|
|
|
|
|
|
|
`doc` (`Map`, read-only)::
|
|
|
|
Contains the fields of the current document where each field is a
|
|
|
|
`List` of values.
|
|
|
|
|
|
|
|
`_score` (`double` read-only)::
|
|
|
|
The similarity score of the current document.
|
|
|
|
|
|
|
|
*Side Effects*
|
|
|
|
|
2018-08-10 13:21:54 -04:00
|
|
|
`state` (`Map`)::
|
2018-07-02 17:44:36 -04:00
|
|
|
Use this `Map` to add values for processing in a combine script.
|
|
|
|
Additional values must be of the type `Map`, `List`, `String` or
|
2018-08-10 13:21:54 -04:00
|
|
|
primitive. The same `state` `Map` is shared between all aggregated documents
|
|
|
|
on a given shard. If an initialization script is provided as part of the
|
2018-07-02 17:44:36 -04:00
|
|
|
aggregation then values added from the initialization script are
|
2018-08-10 13:21:54 -04:00
|
|
|
available. If no combine script is specified, values must be
|
|
|
|
directly stored in `state` in a usable form. If no combine script and no
|
2018-07-02 17:44:36 -04:00
|
|
|
<<painless-metric-agg-reduce-context, reduce script>> are specified, the
|
2018-08-10 13:21:54 -04:00
|
|
|
`state` values are used as the result.
|
2018-07-02 17:44:36 -04:00
|
|
|
|
|
|
|
*Return*
|
|
|
|
|
|
|
|
`void`::
|
|
|
|
No expected return value.
|
|
|
|
|
|
|
|
*API*
|
|
|
|
|
|
|
|
The standard <<painless-api-reference, Painless API>> is available.
|