| 1234567891011121314151617181920212223242526272829 | [[stored-scripts]]==== Stored Scripts APIThe stored script API allows one to interact with scripts and templatesstored in Elasticsearch. It can be used to create, update, get,and delete stored scripts and templates.[source,java]--------------------------------------------------PutStoredScriptResponse response = client.admin().cluster().preparePutStoredScript()                .setId("script1")                .setContent(new BytesArray("{\"script\": {\"lang\": \"painless\", \"source\": \"_score * doc['my_numeric_field'].value\"} }"), XContentType.JSON)                .get();GetStoredScriptResponse response = client().admin().cluster().prepareGetStoredScript()                .setId("script1")                .get();DeleteStoredScriptResponse response = client().admin().cluster().prepareDeleteStoredScript()                .setId("script1")                .get();--------------------------------------------------To store templates simply use "mustache" for the scriptLang.===== Script LanguageThe put stored script API allows one to set the language of the stored script.If one is not provided the default scripting language will be used.
 |