/**
* Save a model instance.
*
* @throws \Exception
*
* @return mixed
*/
public function save()
{
$this->exitIfModelNotSet();
if (!$this->model->exists) {
throw new \Exception('Model not persisted yet');
}
$document = $this->model->getDocumentData();
$params = ['id' => $this->model->getKey(), 'type' => $this->model->getDocumentType(), 'index' => $this->model->getDocumentIndex(), 'body' => $document];
return $this->connection->indexStatement($params);
}