Ejemplo n.º 1
0
	/**
	 * Update document, using update script. Requires elasticsearch >= 0.19.0
	 *
	 * @param int $id document id
	 * @param Elastica_Script $script script to use for update
	 * @param string $index index to update
	 * @param string $type type of index to update
	 * @param array $options array of query params to use for query. For possible options check es api
	 * @return Elastica_Response
	 * @link http://www.elasticsearch.org/guide/reference/api/update.html
	 */
	public function updateDocument($id, Elastica_Script $script, $index, $type, array $options = array()) {
		$path =  $index . '/' . $type . '/' . $id . '/_update';
		if (!isset($options['retry_on_conflict'])) {
			$retryOnConflict = $this->getConfig("retryOnConflict");
			$options['retry_on_conflict'] = $retryOnConflict;
		}

		$data = array(
			'script' => $script->getScript(),
		);
		if ($script->getLang() != null) {
			$data['lang'] = $script->getLang();
		}
		if ($script->getParams() != null) {
			$data['params'] = $script->getParams();
		}

		return $this->request($path, Elastica_Request::POST, $data, $options);
	}
Ejemplo n.º 2
0
	/**
	 * Add a filter with a script to calculate the score
	 *
	 * @param Elastica_Filter_Abstract $filter Filter object
	 * @param Elastica_Script $script Script for calculating the score
	 * @return Elastica_Query_CustomFiltersScore Current object
	 */
	public function addFilterScript(Elastica_Filter_Abstract $filter, Elastica_Script $script) {
		$filterParam = array('filter' => $filter->toArray(), 'script' => $script->getScript());
		$this->addParam('filters', $filterParam);
		return $this;
	}