2016-05-04 12:17:10 -04:00
|
|
|
[[modules-scripting]]
|
2019-06-06 10:45:04 -04:00
|
|
|
= Scripting
|
2013-08-28 19:24:34 -04:00
|
|
|
|
2019-06-06 10:45:04 -04:00
|
|
|
[partintro]
|
|
|
|
--
|
|
|
|
With scripting, you can evaluate custom expressions in {es}. For example, you
|
|
|
|
could use a script to return "script fields" as part of a search request or
|
|
|
|
evaluate a custom score for a query.
|
2016-05-04 12:17:10 -04:00
|
|
|
|
2016-08-30 12:06:18 -04:00
|
|
|
The default scripting language is <<modules-scripting-painless, `Painless`>>.
|
2016-05-04 12:17:10 -04:00
|
|
|
Additional `lang` plugins enable you to run scripts written in other languages.
|
|
|
|
Everywhere a script can be used, you can include a `lang` parameter
|
|
|
|
to specify the language of the script.
|
|
|
|
|
|
|
|
[float]
|
2019-06-06 10:45:04 -04:00
|
|
|
== General-purpose languages
|
2016-05-04 12:17:10 -04:00
|
|
|
|
|
|
|
These languages can be used for any purpose in the scripting APIs,
|
|
|
|
and give the most flexibility.
|
|
|
|
|
|
|
|
[cols="<,<,<",options="header",]
|
|
|
|
|=======================================================================
|
|
|
|
|Language
|
|
|
|
|Sandboxed
|
|
|
|
|Required plugin
|
|
|
|
|
|
|
|
|<<modules-scripting-painless, `painless`>>
|
|
|
|
|yes
|
|
|
|
|built-in
|
|
|
|
|
|
|
|
|=======================================================================
|
|
|
|
|
|
|
|
[float]
|
2019-06-06 10:45:04 -04:00
|
|
|
== Special-purpose languages
|
2016-05-04 12:17:10 -04:00
|
|
|
|
|
|
|
These languages are less flexible, but typically have higher performance for
|
|
|
|
certain tasks.
|
|
|
|
|
|
|
|
[cols="<,<,<,<",options="header",]
|
|
|
|
|=======================================================================
|
|
|
|
|Language
|
|
|
|
|Sandboxed
|
|
|
|
|Required plugin
|
|
|
|
|Purpose
|
|
|
|
|
|
|
|
|<<modules-scripting-expression, `expression`>>
|
|
|
|
|yes
|
|
|
|
|built-in
|
|
|
|
|fast custom ranking and sorting
|
|
|
|
|
|
|
|
|<<search-template, `mustache`>>
|
|
|
|
|yes
|
|
|
|
|built-in
|
|
|
|
|templates
|
|
|
|
|
2017-05-11 15:15:16 -04:00
|
|
|
|<<modules-scripting-engine, `java`>>
|
2016-05-04 12:17:10 -04:00
|
|
|
|n/a
|
|
|
|
|you write it!
|
|
|
|
|expert API
|
|
|
|
|
|
|
|
|=======================================================================
|
|
|
|
|
|
|
|
[WARNING]
|
|
|
|
.Scripts and security
|
|
|
|
=================================================
|
|
|
|
|
|
|
|
Languages that are sandboxed are designed with security in mind. However, non-
|
|
|
|
sandboxed languages can be a security issue, please read
|
|
|
|
<<modules-scripting-security, Scripting and security>> for more details.
|
|
|
|
|
|
|
|
=================================================
|
2019-06-06 10:45:04 -04:00
|
|
|
--
|
2016-05-04 12:17:10 -04:00
|
|
|
|
|
|
|
include::scripting/using.asciidoc[]
|
|
|
|
|
|
|
|
include::scripting/fields.asciidoc[]
|
2013-08-28 19:24:34 -04:00
|
|
|
|
2016-01-31 08:54:17 -05:00
|
|
|
include::scripting/security.asciidoc[]
|
2016-05-04 12:17:10 -04:00
|
|
|
|
|
|
|
include::scripting/painless.asciidoc[]
|
|
|
|
|
|
|
|
include::scripting/expression.asciidoc[]
|
|
|
|
|
2017-05-11 15:15:16 -04:00
|
|
|
include::scripting/engine.asciidoc[]
|