public function commit(array $params = [])
    {
        if (!empty($this->bulkQueries)) {
            $bulkQueries = array_merge($this->bulkQueries, $this->bulkParams);
            $bulkQueries['index']['_index'] = $this->getIndexName();
            $this->eventDispatcher->dispatch(
                Events::PRE_COMMIT,
                new CommitEvent($this->getCommitMode(), $bulkQueries)
            );

            $this->stopwatch('start', 'bulk');
            $bulkResponse = $this->client->bulk($bulkQueries);
            $this->stopwatch('stop', 'bulk');

            if ($bulkResponse['errors']) {
                throw new BulkWithErrorsException(
                    json_encode($bulkResponse),
                    0,
                    null,
                    $bulkResponse
                );
            }

            $this->bulkQueries = [];
            $this->bulkCount = 0;

            $this->stopwatch('start', 'refresh');

            switch ($this->getCommitMode()) {
                case 'flush':
                    $this->flush($params);
                    break;
                case 'refresh':
                    $this->refresh($params);
                    break;
            }

            $this->eventDispatcher->dispatch(
                Events::POST_COMMIT,
                new CommitEvent($this->getCommitMode(), $bulkResponse)
            );

            $this->stopwatch('stop', 'refresh');

            return $bulkResponse;
        }

        return null;
    }
public function commit(array $params = [])
    {
        if (!empty($this->bulkQueries)) {
            $bulkQueries = array_merge($this->bulkQueries, $this->bulkParams);
            $bulkQueries['index']['_index'] = $this->getIndexName();
            $this->eventDispatcher->dispatch(
                Events::PRE_COMMIT,
                new CommitEvent($this->getCommitMode(), $bulkQueries)
            );

            $this->stopwatch('start', 'bulk');
            $bulkResponse = $this->client->bulk($bulkQueries);
            $this->stopwatch('stop', 'bulk');

            if ($bulkResponse['errors']) {
                throw new BulkWithErrorsException(
                    json_encode($bulkResponse),
                    0,
                    null,
                    $bulkResponse
                );
            }

            $this->bulkQueries = [];
            $this->bulkCount = 0;

            $this->stopwatch('start', 'refresh');

            switch ($this->getCommitMode()) {
                case 'flush':
                    $this->flush($params);
                    break;
                case 'refresh':
                    $this->refresh($params);
                    break;
            }

            $this->eventDispatcher->dispatch(
                Events::POST_COMMIT,
                new CommitEvent($this->getCommitMode(), $bulkResponse)
            );

            $this->stopwatch('stop', 'refresh');

            return $bulkResponse;
        }

        return null;
    }
public function commit ( array $ params = [ ] ) { if ( ! empty ( $ this -> bulkQueries ) ) { $ bulkQueries = array_merge ( $ this -> bulkQueries , $ this -> bulkParams ) ; $ bulkQueries [ 'index' ] [ '_index' ] = $ this -> getIndexName ( ) ; $ this -> eventDispatcher -> dispatch ( Events :: PRE_COMMIT , new CommitEvent ( $ this -> getCommitMode ( ) , $ bulkQueries ) ) ; $ this -> stopwatch ( 'start' , 'bulk' ) ; $ bulkResponse = $ this -> client -> bulk ( $ bulkQueries ) ; $ this -> stopwatch ( 'stop' , 'bulk' ) ; if ( $ bulkResponse [ 'errors' ] ) { throw new BulkWithErrorsException ( json_encode ( $ bulkResponse ) , 0 , null , $ bulkResponse ) ; } $ this -> bulkQueries = [ ] ; $ this -> bulkCount = 0 ; $ this -> stopwatch ( 'start' , 'refresh' ) ; switch ( $ this -> getCommitMode ( ) ) { case 'flush' : $ this -> flush ( $ params ) ; break ; case 'refresh' : $ this -> refresh ( $ params ) ; break ; } $ this -> eventDispatcher -> dispatch ( Events :: POST_COMMIT , new CommitEvent ( $ this -> getCommitMode ( ) , $ bulkResponse ) ) ; $ this -> stopwatch ( 'stop' , 'refresh' ) ; return $ bulkResponse ; } return null ; }
Inserts the current query container to the index, used for bulk queries execution.

@param array $params Parameters that will be passed to the flush or refresh queries.

@return null|array

@throws BulkWithErrorsException
Inserts the current query container to the index used for bulk queries execution .