diff options
author | Pierre Schmitz <pierre@archlinux.de> | 2015-08-16 08:22:05 +0200 |
---|---|---|
committer | Pierre Schmitz <pierre@archlinux.de> | 2015-08-16 08:22:05 +0200 |
commit | 1a365e77dfb8825136626202b1df462731b42060 (patch) | |
tree | 1dc4468eaabf070e051e790a9e67a9a9a2c63d99 /vendor/ruflin/elastica/lib/Elastica/Bulk/Action/UpdateDocument.php | |
parent | a72fd280f7acb4d2a1ba579a0f1b2b2ae8958530 (diff) |
Update to MediaWiki 1.25.2
Diffstat (limited to 'vendor/ruflin/elastica/lib/Elastica/Bulk/Action/UpdateDocument.php')
-rw-r--r-- | vendor/ruflin/elastica/lib/Elastica/Bulk/Action/UpdateDocument.php | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/vendor/ruflin/elastica/lib/Elastica/Bulk/Action/UpdateDocument.php b/vendor/ruflin/elastica/lib/Elastica/Bulk/Action/UpdateDocument.php new file mode 100644 index 00000000..4c1dbaa4 --- /dev/null +++ b/vendor/ruflin/elastica/lib/Elastica/Bulk/Action/UpdateDocument.php @@ -0,0 +1,69 @@ +<?php + +namespace Elastica\Bulk\Action; + +use Elastica\Document; +use Elastica\Script; + +/** + * @package Elastica\Bulk\Action + * @link http://www.elasticsearch.org/guide/reference/api/bulk/ + */ +class UpdateDocument extends IndexDocument +{ + /** + * @var string + */ + protected $_opType = self::OP_TYPE_UPDATE; + + /** + * Set the document for this bulk update action. + * @param \Elastica\Document $document + * @return \Elastica\Bulk\Action\UpdateDocument + */ + public function setDocument(Document $document) + { + parent::setDocument($document); + + $source = array('doc' => $document->getData()); + + if ($document->getDocAsUpsert()) { + $source['doc_as_upsert'] = true; + + }else if ($document->hasUpsert()) { + + $upsert = $document->getUpsert()->getData(); + + if (!empty($upsert)) { + $source['upsert'] = $upsert; + } + } + + $this->setSource($source); + + return $this; + } + + /** + * @param \Elastica\Script $script + * @return \Elastica\Bulk\Action\AbstractDocument + */ + public function setScript(Script $script) + { + parent::setScript($script); + + $source = $script->toArray(); + + if ($script->hasUpsert()) { + $upsert = $script->getUpsert()->getData(); + + if (!empty($upsert)) { + $source['upsert'] = $upsert; + } + } + + $this->setSource($source); + + return $this; + } +} |