This is a cache of https://www.elastic.co/guide/en/elasticsearch/painless/8.19/painless-contexts.html. It is a snapshot of the page as it appeared on 2025-11-24T06:20:26.782+0000.
Painless contexts | Painless Scripting Language [8.19] | Elastic
IMPORTANT: This documentation is no longer updated. Refer to Elastic's version policy and the latest documentation.

Painless contexts

edit

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.

Painless scripts typically run within one of the contexts in the following table. Before using a Painless context, configure the example data. Each context example is configured to operate on this data.