/** * Update document, using update script. Requires elasticsearch >= 0.19.0 * * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/docs-update.html * @throws \Elastica\Exception\InvalidException * * @param \Elastica\Document|\Elastica\Script $data Document with update data * @param array $options array of query params to use for query. For possible options check es api * @return \Elastica\Response */ public function updateDocument($data, array $options = array()) { if (!$data instanceof Document && !$data instanceof Script) { throw new \InvalidArgumentException("Data should be a Document or Script"); } if (!$data->hasId()) { throw new InvalidException('Document or Script id is not set'); } $id = urlencode($data->getId()); return $this->getIndex()->getClient()->updateDocument($id, $data, $this->getIndex()->getName(), $this->getName(), $options); }