public function index(Document $document)
{
$result = $this->client->request('POST', "/{$this->indexName}/{$document->type}/{$document->id}", new Message(array('Content-Type' => 'application/json'), $json = $this->serializer->getIndexDocument($document)));
$this->flush();
if ($result->headers['status'] !== 201 && $result->headers['status'] !== 200) {
throw new RuntimeException('Wrong HTTP status received from Elasticsearch: ' . $result->headers['status']);
}
}