Update a document

POST /{index}/_update/{id}

Updates a document by running a script or passing a partial document.

Path parameters

  • index string Required

    The name of the index

  • id string Required

    Document ID

Query parameters

  • Only perform the operation if the document has this primary term.

  • Only perform the operation if the document has this sequence number.

  • lang string

    The script language.

  • refresh string

    If 'true', Elasticsearch refreshes the affected shards to make this operation visible to search, if 'wait_for' then wait for a refresh to make this operation visible to search, if 'false' do nothing with refreshes.

    Values are true, false, or wait_for.

  • If true, the destination must be an index alias.

  • Specify how many times should the operation be retried when a conflict occurs.

  • routing string

    Custom value used to route operations to a specific shard.

  • timeout string

    Period to wait for dynamic mapping updates and active shards. This guarantees Elasticsearch waits for at least the timeout before failing. The actual wait time could be longer, particularly when multiple waits occur.

  • wait_for_active_shards number | string

    The number of shard copies that must be active before proceeding with the operations. Set to 'all' or any positive integer up to the total number of shards in the index (number_of_replicas+1). Defaults to 1 meaning the primary shard.

  • _source boolean | string | array[string]

    Set to false to disable source retrieval. You can also specify a comma-separated list of the fields you want to retrieve.

  • _source_excludes string | array[string]

    Specify the source fields you want to exclude.

  • _source_includes string | array[string]

    Specify the source fields you want to retrieve.

application/json

Body Required

Responses

POST /{index}/_update/{id}
curl \
 -X POST http://api.example.com/{index}/_update/{id} \
 -H "Content-Type: application/json" \
 -d '{"detect_noop":true,"doc":{},"doc_as_upsert":true,"script":{"source":"string","id":"string","params":{"key":{}},"":"painless","options":{"key":"string"}},"scripted_upsert":true,"":true,"upsert":{}}'