[[modules-scripting]]
= Scripting

[partintro]
--
With scripting, you can evaluate custom expressions in {es}. For example, you
can use a script to return a computed value as a field or evaluate a custom
score for a query.

The default scripting language is <<modules-scripting-painless,Painless>>.
Additional `lang` plugins are available to run scripts written in other
languages. You can specify the language of the script anywhere that scripts run.

[discrete]
[[scripting-available-languages]]
== Available scripting languages

Painless is purpose-built for {es}, can be used for any purpose in the
scripting APIs, and provides the most flexibility. The other languages are less
flexible, but can be useful for specific purposes.

[cols="<,<,<,<",options="header",]
|========
|Language
    |Sandboxed
    |Required plugin
    |Purpose

|<<modules-scripting-painless,`painless`>>
    |{yes-icon}
    |Built-in
    |Purpose-built for {es}

|<<modules-scripting-expression, `expression`>>
    |{yes-icon}
    |Built-in
    |Fast custom ranking and sorting

|<<search-template, `mustache`>>
    |{yes-icon}
    |Built-in
    |Templates

|<<modules-scripting-engine, `java`>>
    |{no-icon}
    |You write it!
    |Expert API
|========

--

include::scripting/painless.asciidoc[]

include::scripting/using.asciidoc[]

include::scripting/access-fields.asciidoc[]

include::scripting/common-script-uses.asciidoc[]

include::scripting/fields.asciidoc[]

include::scripting/security.asciidoc[]

include::scripting/expression.asciidoc[]

include::scripting/engine.asciidoc[]
