Command.php
public function insert($index, $type, $data, $id = null, $options = [])
    {
        if (empty($data)) {
            $body = '{}';
        } else {
            $body = is_array($data) ? Json::encode($data) : $data;
        }

        if ($id !== null) {
            return $this->db->put([$index, $type, $id], $options, $body);
        } else {
            return $this->db->post([$index, $type], $options, $body);
        }
    }
public function insert($index, $type, $data, $id = null, $options = [])
    {
        if (empty($data)) {
            $body = '{}';
        } else {
            $body = is_array($data) ? Json::encode($data) : $data;
        }

        if ($id !== null) {
            return $this->db->put([$index, $type, $id], $options, $body);
        } else {
            return $this->db->post([$index, $type], $options, $body);
        }
    }
public function insert ( $ index , $ type , $ data , $ id = null , $ options = [ ] ) { if ( empty ( $ data ) ) { $ body = '{}' ; } else { $ body = is_array ( $ data ) ? Json :: encode ( $ data ) : $ data ; } if ( $ id !== null ) { return $ this -> db -> put ( [ $ index , $ type , $ id ] , $ options , $ body ) ; } else { return $ this -> db -> post ( [ $ index , $ type ] , $ options , $ body ) ; } }
Inserts a document into an index
@param string $index
@param string $type
@param string|array $data json string or array of data to store
@param null $id the documents id. If not specified Id will be automatically chosen
@param array $options
@return mixed
@see http://www.elastic.co/guide/en/elasticsearch/reference/current/docs-index_.html
Inserts a document into an index