yii\elasticsearch\Connection::put PHP Method

put() public method

Performs PUT HTTP request
public put ( string | array $url, array $options = [], string $body = null, boolean $raw = false ) : mixed
$url string | array URL
$options array URL options
$body string request body
$raw boolean if response body contains JSON and should be decoded
return mixed response
    public function put($url, $options = [], $body = null, $raw = false)
    {
        $this->open();
        return $this->httpRequest('PUT', $this->createUrl($url, $options), $body, $raw);
    }

Usage Example

Example #1
0
 /**
  * @param $name
  * @param $pattern
  * @param $settings
  * @param $mappings
  * @param integer $order
  * @return mixed
  * @see http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-templates.html
  */
 public function createTemplate($name, $pattern, $settings, $mappings, $order = 0)
 {
     $body = Json::encode(['template' => $pattern, 'order' => $order, 'settings' => (object) $settings, 'mappings' => (object) $mappings]);
     return $this->db->put(['_template', $name], [], $body);
 }