Partial document update

edit

If you want to partially update a document (e.g. change an existing field, or add a new one) you can do so by specifying the doc in the body parameter. This will merge the fields in doc with the existing document:

$params = [
    'index' => 'my_index',
    'type' => 'my_type',
    'id' => 'my_id',
    'body' => [
        'doc' => [
            'new_field' => 'abc'
        ]
    ]
];

// Update doc at /my_index/my_type/my_id
$response = $client->update($params);