Skip to content

Commit

Permalink
Update docs about script parameter (#27010)
Browse files Browse the repository at this point in the history
Added a description of short script form. Also removed references to the obsolete `script.default_lang`.
  • Loading branch information
pozhidaevak authored and rjernst committed Oct 16, 2017
1 parent 4b9a28e commit ddacfdd
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 6 deletions.
4 changes: 2 additions & 2 deletions docs/reference/docs/update-by-query.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ parameter in the same way as the search api.
So far we've only been updating documents without changing their source. That
is genuinely useful for things like
<<picking-up-a-new-property,picking up new properties>> but it's only half the
fun. `_update_by_query` supports a `script` object to update the document. This
will increment the `likes` field on all of kimchy's tweets:
fun. `_update_by_query` <<modules-scripting-using,supports scripts>> to update
the document. This will increment the `likes` field on all of kimchy's tweets:

[source,js]
--------------------------------------------------
Expand Down
29 changes: 25 additions & 4 deletions docs/reference/modules/scripting/using.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,7 @@ GET my_index/_search

`lang`::

Specifies the language the script is written in. Defaults to `painless` but
may be set to any of languages listed in <<modules-scripting>>. The
default language may be changed in the `elasticsearch.yml` config file by
setting `script.default_lang` to the appropriate language.
Specifies the language the script is written in. Defaults to `painless`.


`source`, `id`::
Expand Down Expand Up @@ -108,6 +105,30 @@ minute will be compiled. You can change this setting dynamically by setting
========================================

[float]
[[modules-scripting-short-script-form]]
=== Short Script Form
A short script form can be used for brevity. In the short form, `script` is represented
by a string instead of an object. This string contains the source of the script.

Short form:

[source,js]
----------------------
"script": "ctx._source.likes++"
----------------------
// NOTCONSOLE

The same script in the normal form:

[source,js]
----------------------
"script": {
"source": "ctx._source.likes++"
}
----------------------
// NOTCONSOLE

[float]
[[modules-scripting-stored-scripts]]
=== Stored Scripts
Expand Down

0 comments on commit ddacfdd

Please sign in to comment.