代码:
<?php
require 'vendor/autoload.php';
use Elasticsearch\ClientBuilder;
$client = ClientBuilder::create()->build();
$params = [
'index' => 'shop',
'type' => 'users',
'id' => 'RTUuWHoBEUYxPF1yvn-9', // 通过id 更新
'body' => [
'doc' => [
'name' => '张四是谁呀'
]
]
];
// 更新
$response = $client->update($params);
echo json_encode($response);
响应:
{
"_index": "shop",
"_type": "users",
"_id": "RTUuWHoBEUYxPF1yvn-9",
"_version": 2,
"result": "updated",
"_shards": {
"total": 2,
"successful": 1,
"failed": 0
},
"_seq_no": 6,
"_primary_term": 1
}