【Elasticsearch PHP版】更新文档

代码:

<?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
}

【Elasticsearch PHP版】更新文档

上一篇:疫情环境下的网络学习笔记 python 4.3


下一篇:Vue_shop项目