Elasticsearch索引更新文档字段

Elasticsearch搜索引擎的基本操作

    示例脚本:

     #!/usr/bin/env bash
      curl -XPOST 'localhost:9200/document/table/90332/_update?pretty' -d  '
      {  
        "doc":
           { 
            "tag": "Jane Doe", 
            "test": 20
           }
      }'

PHP脚本示例:

$params = [
    'index' => 'document',
    'type' => 'table',
    'id' => '90332',
    'body' => [
        'doc' => [
            'tag' => 'Jane Doe',
            'test'=>20,
        ]
    ]
];

$response = $client->update($params);

然后查询结果为:

{
   "_index":"document",
   "_type":"table",
   "_id":"90332",
   "_version":2,
   "found":true,
   "_source":{
           "buy_id":"90332",
           "push_time":1440663517,
           "user_ids":["100405","100406","100419","100495","100520","100523","100527","100643","100670"],
           "test":20,
           "tag":"Jane Doe"
   }
}

OK,更新成功了。



0 评论

发表评论

电子邮件地址不会被公开。 必填项已用*标注