private function createIndex()
 {
     $maxShardsPerNode = $this->maxShardsPerNode === 'unlimited' ? -1 : $this->maxShardsPerNode;
     // This is "create only" for now.
     if ($this->getIndex()->exists()) {
         throw new \Exception("Index already exists.");
     }
     $mappingConfigBuilder = new SuggesterMappingConfigBuilder();
     // We create the index with 0 replicas, this is faster and will
     // stress less nodes with 4 shards and 2 replicas we would
     // stress 12 nodes (moreover with the optimize flag)
     $settings = array('number_of_shards' => $this->getShardCount(), 'auto_expand_replicas' => "0-0", 'analysis' => $this->analysisConfigBuilder->buildConfig(), 'routing.allocation.total_shards_per_node' => $maxShardsPerNode);
     if ($this->hasOption('allocationIncludeTag')) {
         $this->output("Using routing.allocation.include.tag: {$this->getOption('allocationIncludeTag')}, " . "the index might be stuck in red if the cluster is not properly configured.\n");
         $settings['routing.allocation.include.tag'] = $this->getOption('allocationIncludeTag');
     }
     if ($this->hasOption('allocationExcludeTag')) {
         $this->output("Using routing.allocation.exclude.tag: {$this->getOption('allocationExcludeTag')}, " . "the index might be stuck in red if the cluster is not properly configured.\n");
         $settings['routing.allocation.exclude.tag'] = $this->getOption('allocationExcludeTag');
     }
     $args = array('settings' => $settings, 'mappings' => $mappingConfigBuilder->buildConfig());
     // @todo utilize $this->getIndex()->create(...) once it supports setting
     // the master_timeout parameter.
     $this->getIndex()->request('', Request::PUT, $args, array('master_timeout' => $this->masterTimeout));
     // Index create is async, we have to make sure that the index is ready
     // before sending any docs to it.
     $this->waitForGreen();
 }
 private function createMapping()
 {
     $type = $this->getType();
     $mappingConfigBuilder = new SuggesterMappingConfigBuilder();
     $validator = new \CirrusSearch\Maintenance\Validators\MappingValidator($this->getIndex(), false, $this->availablePlugins, $mappingConfigBuilder->buildConfig(), array(Connection::TITLE_SUGGEST_TYPE_NAME => $type), $this);
     $status = $validator->validate();
     if (!$status->isOK()) {
         $this->error($status->getMessage()->text(), 1);
     }
 }