Elasticsearch\Bulk::update PHP Method

update() public method

Update a part of a document
public update ( array $partialDocument, mixed $id, string $index, string $type, array $options = [] ) : Bulk
$partialDocument array
$id mixed
$index string Index
$type string Type
$options array Allow sending query parameters to control indexing further _refresh_ *bool* If set to true, immediately refresh the shard after indexing
return Bulk
    public function update($partialDocument, $id, $index, $type, array $options = array())
    {
        $params = array('_id' => $id, '_index' => $index, '_type' => $type);
        foreach ($options as $key => $value) {
            $params['_' . $key] = $value;
        }
        $operation = array(array('update' => $params), array('doc' => $partialDocument));
        $this->operations[] = $operation;
        return $this;
    }

Usage Example

Example #1
0
 /**
  * Update a part of a document
  *
  * @return array
  *
  * @param array $partialDocument
  * @param mixed $id
  * @param array $options Allow sending query parameters to control indexing further
  *                        _refresh_ *bool* If set to true, immediately refresh the shard after indexing
  */
 public function update($partialDocument, $id, $options = array())
 {
     if ($this->bulk) {
         return $this->bulk->update($partialDocument, $id, $this->index, $this->type, $options);
     }
     return $this->transport->update($partialDocument, $id, $options);
 }