eZ\Publish\Core\Search\Elasticsearch\Content\Gateway\Native::index PHP Method

index() public method

Indexes a given $document.
public index ( Document $document )
$document eZ\Publish\Core\Search\Elasticsearch\Content\Document
    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']);
        }
    }