/**
  * @return Status
  */
 public function validate()
 {
     $this->outputIndented("Validating analyzers...");
     $settings = $this->index->getSettings()->get();
     $requiredAnalyzers = $this->analysisConfigBuilder->buildConfig();
     if ($this->checkConfig($settings['analysis'], $requiredAnalyzers)) {
         $this->output("ok\n");
     } else {
         $this->output("cannot correct\n");
         return Status::newFatal(new RawMessage("This script encountered an index difference that requires that the index be\n" . "copied, indexed to, and then the old index removed. Re-run this script with the\n" . "--reindexAndRemoveOk --indexIdentifier=now parameters to do this."));
     }
     return Status::newGood();
 }
 /**
  * @param bool $rebuild
  */
 private function createIndex($rebuild)
 {
     $maxShardsPerNode = $this->maxShardsPerNode === 'unlimited' ? -1 : $this->maxShardsPerNode;
     $args = array('settings' => array('number_of_shards' => $this->shardCount, 'auto_expand_replicas' => $this->replicaCount, 'analysis' => $this->analysisConfigBuilder->buildConfig(), 'refresh_interval' => $this->refreshInterval . 's', 'merge.policy' => $this->mergeSettings, 'routing.allocation.total_shards_per_node' => $maxShardsPerNode));
     if ($this->searchAllFields) {
         // Use our weighted all field as the default rather than _all which is disabled.
         $args['settings']['index.query.default_field'] = 'all';
     }
     $this->index->create($args, $rebuild);
 }
 /**
  * Constructor
  * @param string $langCode The language code to build config for
  * @param array(string) $plugins list of plugins installed in Elasticsearch
  */
 public function __construct($langCode, $plugins)
 {
     parent::__construct($langCode, $plugins);
 }
 /**
  * @param string $langCode
  * @param array $availablePlugins
  * @return AnalysisConfigBuilder
  */
 protected function pickAnalyzer($langCode, array $availablePlugins = array())
 {
     $analysisConfigBuilder = new AnalysisConfigBuilder($langCode, $availablePlugins);
     $this->outputIndented('Picking analyzer...' . $analysisConfigBuilder->getDefaultTextAnalyzerType() . "\n");
     return $analysisConfigBuilder;
 }