Example #1
0
	/**
	 * @param string $name Name of the Script field
	 * @param Elastica_Script $script
	 * @return Elastica_ScriptFields
	 */
	public function addScript($name, Elastica_Script $script) {
		if (!is_string($name) || !strlen($name)) {
			throw new Elastica_Exception_Invalid('The name of a Script is required and must be a string');
		}
		$this->setParam($name, $script->toArray());

		return $this;
	}
Example #2
0
 /**
  * Adds a Script to the query
  *
  * @param  Elastica_Script $script Script object
  * @return Elastica_Query  Query object
  */
 public function addScriptField($name, Elastica_Script $script)
 {
     $this->_params['script_fields'][$name] = $script->toArray();
     return $this;
 }