Skip to content
This repository was archived by the owner on Sep 21, 2021. It is now read-only.

Commit 6b788f2

Browse files
committed
Edited 030_Data/45_Partial_update.asciidoc with Atlas code editor
1 parent 31a9f4c commit 6b788f2

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

030_Data/45_Partial_update.asciidoc

+15-15
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,21 @@ Retrieving the document shows the updated `_source` field:
7272
==== Using Scripts to Make Partial Updates
7373

7474
.Scripting with Groovy
75+
76+
Scripts can be used in the `update` API to change the contents of the `_source`
77+
field, which ((("_source field", sortas="source field")))is referred to inside an update script as `ctx._source`. For
78+
instance, we could use a script to increment the number of `views` that our
79+
blog post has had:
80+
81+
[source,js]
82+
--------------------------------------------------
83+
POST /website/blog/1/_update
84+
{
85+
"script" : "ctx._source.views+=1"
86+
}
87+
--------------------------------------------------
88+
// SENSE: 030_Data/45_Partial_update.json
89+
7590
****
7691
7792
For those ((("documents", "partial updates", "using scripts")))((("updating documents", "partial updates", "using scripts")))moments when the API just isn't enough, Elasticsearch allows you to
@@ -90,21 +105,6 @@ http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/modules-sc
90105
91106
****
92107

93-
Scripts can be used in the `update` API to change the contents of the `_source`
94-
field, which ((("_source field", sortas="source field")))is referred to inside an update script as `ctx._source`. For
95-
instance, we could use a script to increment the number of `views` that our
96-
blog post has had:
97-
98-
[source,js]
99-
--------------------------------------------------
100-
POST /website/blog/1/_update
101-
{
102-
"script" : "ctx._source.views+=1"
103-
}
104-
--------------------------------------------------
105-
// SENSE: 030_Data/45_Partial_update.json
106-
107-
108108
We can also use a script to add a new tag to the `tags` array. In this
109109
example we specify the new tag as a parameter rather than hardcoding it in
110110
the script itself. This allows Elasticsearch to reuse the script in the

0 commit comments

Comments
 (0)