Inheritance: extends Elastica\Bulk\Action\AbstractDocument
 /**
  * @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;
 }
Example #2
0
 /**
  * @param \Elastica\Script\AbstractScript $script
  *
  * @return $this
  */
 public function setScript(AbstractScript $script)
 {
     parent::setScript($script);
     // FIXME: can we throw away toArray cast?
     $source = $script->toArray();
     if ($script->hasUpsert()) {
         $upsert = $script->getUpsert()->getData();
         if (!empty($upsert)) {
             $source['upsert'] = $upsert;
         }
     }
     $this->setSource($source);
     return $this;
 }
 /**
  * Set the document for this bulk update action.
  * If the given Document object has a script, the script will be used in the update operation.
  * @param \Elastica\Document $document
  * @return \Elastica\Bulk\Action\IndexDocument
  */
 public function setDocument(Document $document)
 {
     parent::setDocument($document);
     if ($document->hasScript()) {
         $source = $document->getScript()->toArray();
         $documentData = $document->getData();
         if (!empty($documentData)) {
             $source['upsert'] = $documentData;
         }
         $this->setSource($source);
     } else {
         $this->setSource(array('doc' => $document->getData()));
     }
     return $this;
 }