2014-07-16 06:17:57 -04:00
|
|
|
[[indexed-scripts]]
|
|
|
|
== Indexed Scripts API
|
|
|
|
|
|
|
|
The indexed script API allows one to interact with scripts and templates
|
|
|
|
stored in an elasticsearch index. It can be used to create, update, get,
|
|
|
|
and delete indexed scripts and templates.
|
|
|
|
|
|
|
|
[source,java]
|
|
|
|
--------------------------------------------------
|
|
|
|
PutIndexedScriptResponse = client.preparePutIndexedScript()
|
2016-06-27 09:55:16 -04:00
|
|
|
.setScriptLang("painless")
|
2014-07-16 06:17:57 -04:00
|
|
|
.setId("script1")
|
2015-12-22 06:40:28 -05:00
|
|
|
.setSource("script", "_score * doc['my_numeric_field'].value")
|
2014-07-16 06:17:57 -04:00
|
|
|
.execute()
|
|
|
|
.actionGet();
|
|
|
|
|
|
|
|
GetIndexedScriptResponse = client.prepareGetIndexedScript()
|
2016-06-27 09:55:16 -04:00
|
|
|
.setScriptLang("painless")
|
2014-07-16 06:17:57 -04:00
|
|
|
.setId("script1")
|
|
|
|
.execute()
|
|
|
|
.actionGet();
|
|
|
|
|
|
|
|
DeleteIndexedScriptResponse = client.prepareDeleteIndexedScript()
|
2016-06-27 09:55:16 -04:00
|
|
|
.setScriptLang("painless")
|
2014-07-16 06:17:57 -04:00
|
|
|
.setId("script1")
|
|
|
|
.execute()
|
|
|
|
.actionGet();
|
|
|
|
--------------------------------------------------
|
|
|
|
|
|
|
|
To store templates simply use "mustache" for the scriptLang.
|
|
|
|
|
|
|
|
=== Script Language
|
|
|
|
|
|
|
|
The API allows one to set the language of the indexed script being
|
|
|
|
interacted with. If one is not provided the default scripting language
|
2016-06-27 09:55:16 -04:00
|
|
|
will be used.
|