/** * @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; }
/** * @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; }