src/Console/ElasticMigrateCommand.php
protected function updateTargetIndex()
    {
        $targetIndex = $this->argument('target-index');

        $sourceIndexConfigurator = $this->getModel()
            ->getIndexConfigurator();

        $targetIndexPayload = (new RawPayload())
            ->set('index', $targetIndex)
            ->get();

        $indices = ElasticClient::indices();

        try {
            $indices->close($targetIndexPayload);

            if ($settings = $sourceIndexConfigurator->getSettings()) {
                $targetIndexSettingsPayload = (new RawPayload())
                    ->set('index', $targetIndex)
                    ->set('body.settings', $settings)
                    ->get();

                $indices->putSettings($targetIndexSettingsPayload);
            }

            if ($defaultMapping = $sourceIndexConfigurator->getDefaultMapping()) {
                $targetIndexMappingPayload = (new RawPayload())
                    ->set('index', $targetIndex)
                    ->set('type', '_default_')
                    ->set('body._default_', $defaultMapping)
                    ->get();

                $indices->putMapping($targetIndexMappingPayload);
            }

            $indices->open($targetIndexPayload);
        } catch (Exception $exception) {
            $indices->open($targetIndexPayload);

            throw $exception;
        }

        $this->info(sprintf(
            'The index %s was updated.',
            $targetIndex
        ));
    }
protected function updateTargetIndex()
    {
        $targetIndex = $this->argument('target-index');

        $sourceIndexConfigurator = $this->getModel()
            ->getIndexConfigurator();

        $targetIndexPayload = (new RawPayload())
            ->set('index', $targetIndex)
            ->get();

        $indices = ElasticClient::indices();

        try {
            $indices->close($targetIndexPayload);

            if ($settings = $sourceIndexConfigurator->getSettings()) {
                $targetIndexSettingsPayload = (new RawPayload())
                    ->set('index', $targetIndex)
                    ->set('body.settings', $settings)
                    ->get();

                $indices->putSettings($targetIndexSettingsPayload);
            }

            if ($defaultMapping = $sourceIndexConfigurator->getDefaultMapping()) {
                $targetIndexMappingPayload = (new RawPayload())
                    ->set('index', $targetIndex)
                    ->set('type', '_default_')
                    ->set('body._default_', $defaultMapping)
                    ->get();

                $indices->putMapping($targetIndexMappingPayload);
            }

            $indices->open($targetIndexPayload);
        } catch (Exception $exception) {
            $indices->open($targetIndexPayload);

            throw $exception;
        }

        $this->info(sprintf(
            'The index %s was updated.',
            $targetIndex
        ));
    }
protected function updateTargetIndex ( ) { $ targetIndex = $ this -> argument ( 'target-index' ) ; $ sourceIndexConfigurator = $ this -> getModel ( ) -> getIndexConfigurator ( ) ; $ targetIndexPayload = ( new RawPayload ( ) ) -> set ( 'index' , $ targetIndex ) -> get ( ) ; $ indices = ElasticClient :: indices ( ) ; try { $ indices -> close ( $ targetIndexPayload ) ; if ( $ settings = $ sourceIndexConfigurator -> getSettings ( ) ) { $ targetIndexSettingsPayload = ( new RawPayload ( ) ) -> set ( 'index' , $ targetIndex ) -> set ( 'body.settings' , $ settings ) -> get ( ) ; $ indices -> putSettings ( $ targetIndexSettingsPayload ) ; } if ( $ defaultMapping = $ sourceIndexConfigurator -> getDefaultMapping ( ) ) { $ targetIndexMappingPayload = ( new RawPayload ( ) ) -> set ( 'index' , $ targetIndex ) -> set ( 'type' , '_default_' ) -> set ( 'body._default_' , $ defaultMapping ) -> get ( ) ; $ indices -> putMapping ( $ targetIndexMappingPayload ) ; } $ indices -> open ( $ targetIndexPayload ) ; } catch ( Exception $ exception ) { $ indices -> open ( $ targetIndexPayload ) ; throw $ exception ; } $ this -> info ( sprintf ( 'The index %s was updated.' , $ targetIndex ) ) ; }
Update the target index.

@throws \Exception
@return void
Update the target index .