public function bulkIndex(array $documents)
    {
        if (empty($documents)) {
            return;
        }

        $payload = '';
        foreach ($documents as $document) {
            $payload .= $this->serializer->getIndexMetadata($document) . "\n";
            $payload .= $this->serializer->getIndexDocument($document) . "\n";
        }

        $result = $this->client->request(
            'POST',
            "/{$this->indexName}/_bulk",
            new Message(
                array(
                    'Content-Type' => 'application/json',
                ),
                $payload
            )
        );

        if ($result->headers['status'] !== 201 && $result->headers['status'] !== 200) {
            throw new RuntimeException(
                'Wrong HTTP status received from Elasticsearch: ' . $result->headers['status']
            );
        }

        $this->flush();
    }
public function bulkIndex(array $documents)
    {
        if (empty($documents)) {
            return;
        }

        $payload = '';
        foreach ($documents as $document) {
            $payload .= $this->serializer->getIndexMetadata($document) . "\n";
            $payload .= $this->serializer->getIndexDocument($document) . "\n";
        }

        $result = $this->client->request(
            'POST',
            "/{$this->indexName}/_bulk",
            new Message(
                array(
                    'Content-Type' => 'application/json',
                ),
                $payload
            )
        );

        if ($result->headers['status'] !== 201 && $result->headers['status'] !== 200) {
            throw new RuntimeException(
                'Wrong HTTP status received from Elasticsearch: ' . $result->headers['status']
            );
        }

        $this->flush();
    }
public function bulkIndex ( array $ documents ) { if ( empty ( $ documents ) ) { return ; } $ payload = '' ; foreach ( $ documents as $ document ) { $ payload .= $ this -> serializer -> getIndexMetadata ( $ document ) . "\n" ; $ payload .= $ this -> serializer -> getIndexDocument ( $ document ) . "\n" ; } $ result = $ this -> client -> request ( 'POST' , "/{$this->indexName}/_bulk" , new Message ( array ( 'Content-Type' => 'application/json' , ) , $ payload ) ) ; if ( $ result -> headers [ 'status' ] !== 201 && $ result -> headers [ 'status' ] !== 200 ) { throw new RuntimeException ( 'Wrong HTTP status received from Elasticsearch: ' . $ result -> headers [ 'status' ] ) ; } $ this -> flush ( ) ; }
Performs bulk index of a given array of documents.

@param \eZ\Publish\Core\Search\Elasticsearch\Content\Document[] $documents
Performs bulk index of a given array of documents .