public function post($url, $options = [], $body = null, $raw = false) { $this->open(); return $this->httpRequest('POST', $this->createUrl($url, $options), $body, $raw); }
/** * Executes the bulk command. * @return mixed * @throws yii\base\InvalidCallException */ public function execute() { //valid endpoints are /_bulk, /{index}/_bulk, and {index}/{type}/_bulk if ($this->index === null && $this->type === null) { $endpoint = ['_bulk']; } elseif ($this->index !== null && $this->type === null) { $endpoint = [$this->index, '_bulk']; } elseif ($this->index !== null && $this->type !== null) { $endpoint = [$this->index, $this->type, '_bulk']; } else { throw new InvalidCallException('Invalid endpoint: if type is defined, index must be defined too.'); } if (empty($this->actions)) { $body = '{}'; } elseif (is_array($this->actions)) { $body = ''; foreach ($this->actions as $action) { $body .= Json::encode($action) . "\n"; } } else { $body = $this->actions; } return $this->db->post($endpoint, $this->options, $body); }