From 4182e9e3bb881b9bdb8ec67c7d96db65594852c1 Mon Sep 17 00:00:00 2001 From: Martijn van Groningen Date: Wed, 10 Jan 2018 18:03:14 +0100 Subject: [PATCH] docs: Replaces indexed script java api docs with stored script api docs Closes #28144 --- docs/java-api/admin/cluster/index.asciidoc | 1 + .../admin/cluster/stored-scripts.asciidoc | 29 +++++++++++++++ docs/java-api/index.asciidoc | 2 -- docs/java-api/indexed-scripts.asciidoc | 36 ------------------- 4 files changed, 30 insertions(+), 38 deletions(-) create mode 100644 docs/java-api/admin/cluster/stored-scripts.asciidoc delete mode 100644 docs/java-api/indexed-scripts.asciidoc diff --git a/docs/java-api/admin/cluster/index.asciidoc b/docs/java-api/admin/cluster/index.asciidoc index e5525e18a490f..4e1850a34fe47 100644 --- a/docs/java-api/admin/cluster/index.asciidoc +++ b/docs/java-api/admin/cluster/index.asciidoc @@ -13,3 +13,4 @@ In the rest of this guide, we will use `client.admin().cluster()`. include::health.asciidoc[] +include::stored-scripts.asciidoc[] diff --git a/docs/java-api/admin/cluster/stored-scripts.asciidoc b/docs/java-api/admin/cluster/stored-scripts.asciidoc new file mode 100644 index 0000000000000..5ebf89e92be55 --- /dev/null +++ b/docs/java-api/admin/cluster/stored-scripts.asciidoc @@ -0,0 +1,29 @@ +[[stored-scripts]] +==== Stored Scripts API + +The stored script API allows one to interact with scripts and templates +stored 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 Language + +The 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. diff --git a/docs/java-api/index.asciidoc b/docs/java-api/index.asciidoc index 251efff5f8f01..5d53a3c7f1b6d 100644 --- a/docs/java-api/index.asciidoc +++ b/docs/java-api/index.asciidoc @@ -196,6 +196,4 @@ include::aggs.asciidoc[] include::query-dsl.asciidoc[] -include::indexed-scripts.asciidoc[] - include::admin/index.asciidoc[] diff --git a/docs/java-api/indexed-scripts.asciidoc b/docs/java-api/indexed-scripts.asciidoc deleted file mode 100644 index f1877bba1f881..0000000000000 --- a/docs/java-api/indexed-scripts.asciidoc +++ /dev/null @@ -1,36 +0,0 @@ -[[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() - .setScriptLang("painless") - .setId("script1") - .setSource("script", "_score * doc['my_numeric_field'].value") - .execute() - .actionGet(); - -GetIndexedScriptResponse = client.prepareGetIndexedScript() - .setScriptLang("painless") - .setId("script1") - .execute() - .actionGet(); - -DeleteIndexedScriptResponse = client.prepareDeleteIndexedScript() - .setScriptLang("painless") - .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 -will be used.