public function createCommand($indexName, $clientName = null)
    {
        if (!in_array($indexName, $this->indexInformer->getAllIndexNames())) {
            $this->outputFormatted("The index <b>%s</b> is not configured in the current application", [$indexName]);
            $this->quit(1);
        }

        $client = $this->clientFactory->create($clientName);
        try {
            $index = new Index($indexName, $client);
            if ($index->exists()) {
                $this->outputFormatted("The index <b>%s</b> exists", [$indexName]);
                $this->quit(1);
            }
            $index->create();
            $this->outputFormatted("Index <b>%s</b> created with success", [$indexName]);
        } catch (Exception $exception) {
            $this->outputFormatted("Unable to create an index named: <b>%s</b>", [$indexName]);
            $this->quit(1);
        }
    }
public function createCommand($indexName, $clientName = null)
    {
        if (!in_array($indexName, $this->indexInformer->getAllIndexNames())) {
            $this->outputFormatted("The index <b>%s</b> is not configured in the current application", [$indexName]);
            $this->quit(1);
        }

        $client = $this->clientFactory->create($clientName);
        try {
            $index = new Index($indexName, $client);
            if ($index->exists()) {
                $this->outputFormatted("The index <b>%s</b> exists", [$indexName]);
                $this->quit(1);
            }
            $index->create();
            $this->outputFormatted("Index <b>%s</b> created with success", [$indexName]);
        } catch (Exception $exception) {
            $this->outputFormatted("Unable to create an index named: <b>%s</b>", [$indexName]);
            $this->quit(1);
        }
    }
public function createCommand ( $ indexName , $ clientName = null ) { if ( ! in_array ( $ indexName , $ this -> indexInformer -> getAllIndexNames ( ) ) ) { $ this -> outputFormatted ( "The index <b>%s</b> is not configured in the current application" , [ $ indexName ] ) ; $ this -> quit ( 1 ) ; } $ client = $ this -> clientFactory -> create ( $ clientName ) ; try { $ index = new Index ( $ indexName , $ client ) ; if ( $ index -> exists ( ) ) { $ this -> outputFormatted ( "The index <b>%s</b> exists" , [ $ indexName ] ) ; $ this -> quit ( 1 ) ; } $ index -> create ( ) ; $ this -> outputFormatted ( "Index <b>%s</b> created with success" , [ $ indexName ] ) ; } catch ( Exception $ exception ) { $ this -> outputFormatted ( "Unable to create an index named: <b>%s</b>" , [ $ indexName ] ) ; $ this -> quit ( 1 ) ; } }
Create a new index in ElasticSearch

@param string $indexName The name of the new index
@param string $clientName The client name to use
@return void
Create a new index in ElasticSearch