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

Painless Guide

edit

Painless is a simple, secure scripting language designed specifically for use with Elasticsearch. It is the default scripting language for Elasticsearch and can safely be used for inline and stored scripts. For a jump start into Painless, see A Brief Painless Walkthrough. For a detailed description of the Painless syntax and language features, see the Painless Language Specification.

You can use Painless anywhere scripts are used in Elasticsearch. Painless provides:

  • Fast performance: Painless scripts run several times faster than the alternatives.
  • Safety: Fine-grained allowlist with method call/field granularity. See the Painless API Reference for a complete list of available classes and methods.
  • Optional typing: Variables and parameters can use explicit types or the dynamic def type.
  • Syntax: Extends a subset of Java’s syntax to provide additional scripting language features.
  • Optimizations: Designed specifically for Elasticsearch scripting.