Skip to content

Latest commit

 

History

History
44 lines (34 loc) · 1.93 KB

File metadata and controls

44 lines (34 loc) · 1.93 KB
mapped_pages
applies_to
stack serverless
ga
ga
products
id
elasticsearch

How to write Painless scripts [modules-scripting-using]

:::{tip}
This guide provides a beginner-friendly introduction to Painless scripting with step-by-step tutorials and practical examples. If you're new to scripting or Painless, this is the recommended starting point.

For users with Java or Painless experience looking for technical specifications and advanced features, refer to A Brief Painless walkthrough in the Reference section. :::

Wherever scripting is supported in the {{es}} APIs, the syntax follows the same pattern; you specify the language of your script, provide the script logic (or source), and add parameters that are passed into the script:

  "script": {
    "lang":   "...",
    "source" | "id": "...",
    "params": { ... }
  }

lang : Specifies the language the script is written in. Defaults to painless.

source, id : The script itself, which you specify as source for an inline script or id for a stored script. Use the stored script APIs to create and manage stored scripts.

params : Specifies any named parameters that are passed into the script as variables. Use parameters instead of hard-coded values to decrease compile time.

Get started with Painless scripting: