Pumpkin
Pumpkin

Reputation: 2043

Elastic search partial updates without scripting

Is it possible to do partial updates to a document, without using dynamic scripting using the REST API? The requests have to go over http/https.

Upvotes: 1

Views: 697

Answers (1)

pickypg
pickypg

Reputation: 22332

Yes, you can. You can use the doc parameter of the _update endpoint to partially update a document.

$ curl -XPUT host:9200/my-index/my-type/my-id -d '{
  "my_field" : "This is the original value",
  "other_field" : "This field won't be touched by the update"
}'

$ curl -XPOST host:9200/my-index/my-type/my-id/_update -d '{
  "doc" : {
    "my_field" : "changeme"
  }
}'

Note: This does a simple field-level replacement. Do not expect any type of concatenation to occur (for strings or arrays). For that type of behavior, scripts are required (or a two-step request where you fetch, then modify).

Upvotes: 1

Related Questions