예제 #1
0
 /**
  * @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;
 }
예제 #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;
 }