lib/Elastica/Query.php
public function addScriptField($name, AbstractScript $script)
    {
        if (isset($this->_params['script_fields'])) {
            $this->_params['script_fields']->addScript($name, $script);
        } else {
            $this->setScriptFields([$name => $script]);
        }

        return $this;
    }
public function addScriptField($name, AbstractScript $script)
    {
        if (isset($this->_params['script_fields'])) {
            $this->_params['script_fields']->addScript($name, $script);
        } else {
            $this->setScriptFields([$name => $script]);
        }

        return $this;
    }
public function addScriptField ( $ name , AbstractScript $ script ) { if ( isset ( $ this -> _params [ 'script_fields' ] ) ) { $ this -> _params [ 'script_fields' ] -> addScript ( $ name , $ script ) ; } else { $ this -> setScriptFields ( [ $ name => $ script ] ) ; } return $ this ; }
Adds a Script to the query.

@param string                          $name
@param \Elastica\Script\AbstractScript $script Script object

@return $this
Adds a Script to the query .