[[painless-contexts]] == Painless contexts A Painless script is evaluated within a context. Each context has values that are available as local variables, an allowlist 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}/sort-search-results.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-fields.html#script-fields[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] | Bucket selector aggregation | <> | {ref}/search-aggregations-pipeline-bucket-selector-aggregation.html[Elasticsearch Documentation] | Watcher condition | <> | {ref}/condition-script.html[Elasticsearch Documentation] | Watcher transform | <> | {ref}/transform-script.html[Elasticsearch Documentation] |==== include::painless-contexts/index.asciidoc[]