[[painless-contexts]] == Painless contexts A Painless script is evaluated within a context. Each context has values that are available as local variables, a whitelist that controls the available classes, and the methods and fields within those classes (API), and if and what type of value is returned. A Painless script is typically executed within one of the contexts in the table below. Note this is not necessarily a comprehensive list as custom plugins and specialized code may define new ways to use a Painless script. [options="header",cols="<1,<1,<1"] |==== | Name | Painless Documentation | Elasticsearch Documentation | Ingest processor | <> | {ref}/script-processor.html[Elasticsearch Documentation] | Update | <> | {ref}/docs-update.html[Elasticsearch Documentation] | Update by query | <> | {ref}/docs-update-by-query.html[Elasticsearch Documentation] | Reindex | <> | {ref}/docs-reindex.html[Elasticsearch Documentation] | Sort | <> | {ref}/search-request-sort.html[Elasticsearch Documentation] | Similarity | <> | {ref}/index-modules-similarity.html[Elasticsearch Documentation] | Weight | <> | {ref}/index-modules-similarity.html[Elasticsearch Documentation] | Score | <> | {ref}/query-dsl-function-score-query.html[Elasticsearch Documentation] | Field | <> | {ref}/search-request-script-fields.html[Elasticsearch Documentation] | Filter | <> | {ref}/query-dsl-script-query.html[Elasticsearch Documentation] | Minimum should match | <> | {ref}/query-dsl-terms-set-query.html[Elasticsearch Documentation] | Metric aggregation initialization | <> | {ref}/search-aggregations-metrics-scripted-metric-aggregation.html[Elasticsearch Documentation] | Metric aggregation map | <> | {ref}/search-aggregations-metrics-scripted-metric-aggregation.html[Elasticsearch Documentation] | Metric aggregation combine | <> | {ref}/search-aggregations-metrics-scripted-metric-aggregation.html[Elasticsearch Documentation] | Metric aggregation reduce | <> | {ref}/search-aggregations-metrics-scripted-metric-aggregation.html[Elasticsearch Documentation] | Bucket script aggregation | <> | {ref}/search-aggregations-pipeline-bucket-script-aggregation.html[Elasticsearch Documentation] | Watcher condition | <> | {xpack-ref}/condition-script.html[Elasticsearch Documentation] | Watcher transform | <> | {xpack-ref}/transform-script.html[Elasticsearch Documentation] |==== include::painless-contexts/painless-context-examples.asciidoc[] include::painless-contexts/index.asciidoc[]