Skip to content

elasticsearch update-document

update elastic search document


Update a document using the specified script


elasticsearch update-document
    [--site <site>]
    [--cluster <cluster>]
    --index <index>
    [--script <script>]
    [--params <params>]


site - (string)

     Site where this command will be executed
     Example: --site "site-1"
     Default:      Attributes: optional

cluster - (string)

     Name of elastic search cluster
     Example: --cluster "elastic-default"
     Default: elastic-default      Attributes: optional

index - (string)

     Name of the index
     Example: --index "students"
     Default: _None_      Attributes: required

id - (int)

     Unique identifier of the document.
     Example: 1
     Default: _None_      Attributes: required

script - (string)

     Script to be executed on document
     Example: --script "ctx._source.new_field = 'value_of_new_field' or ctx._source.counter += params.count or ctx._source.tags.add(params.tag)"
     Default: _None_      Attributes: optional

params - (string)

     Params that are used in source
     Example: --params "{"count" : 4, "tag": "blue"}"
     Default: _None_      Attributes: optional



x = ! elasticsearch update-document --cluster "elastic-1" --index "my-index-000001" 2 --script "ctx._source.new_field = params.count" --params `{"count" : 4}`
  "_index": "my-index-000001",
  "_type": "_doc",
  "_id": "2",
  "_version": 4,
  "result": "updated",
  "_shards": {
  "total": 2,
    "s  uccessful": 1,
    "failed": 0
  "_seq_no": 7,
  "_primary_term": 1

Access Control

To use this command, you need access to the following:

Field Value
Action "update"
Service Type "elasticsearch"
Service Instance cluster
Object Type "index"
Object ID index

Please see Access Control for details.