Handle index creation command

@param Client $client
@param string $index
@param string $alias
763955
public function handle(Client $client, $index, $alias)
    {
        $settings = $this->configurations->getSettings($alias);

        if (null === $settings) {
            throw new \InvalidArgumentException();
        }

        $client->getIndex($index)->setSettings($settings);
    }
369706
private function createClient($class, $alias)
    {
        if (is_a($class, '\Snc\RedisBundle\Client\Phpredis\Client', true)) {
            $client = new $class(array('alias' => $alias), $this->logger);
        } else {
            $client = new $class();
        }

        return $client;
    }
1060247
protected function getQueryBuilder($alias = null, $indexBy = null)
    {
        $qb = $this->traitGetQueryBuilder($alias, $indexBy);

        $alias = $alias ?: $this->getAlias();

        return $qb
            ->addSelect('translation')
            ->leftJoin($alias . '.translations', 'translation');
    }
526518
public function getCreateIndexSQL(Index $index, $table)
    {
        return parent::getCreateIndexSQL($index, $table) . $this->getAdvancedIndexOptionsSQL($index);
    }
14912
def switch_read_index(new_name)
      new_index = [config.read_alias, new_name].join('_')

      old_index =
        if client.indices.exists_alias?(name: config.read_alias)
          client.indices.get_alias(name: config.read_alias).keys.first
        end

      remove_action =
        ({ remove: { index: old_index, alias: config.read_alias } } if old_index)

      client.indices.update_aliases(body: {
                                      actions: [
                                        remove_action,
                                        { add: { index: new_index, alias: config.read_alias } }
                                      ].compact
                                    })
    end
814572
def set_alias(index_name, delete=True):
    '''
    
    '''
    log.info('Creating alias "{0}" on index "{1}"'.format(
        es.index_name, index_name))
    if es.indices.exists_alias(name=es.index_name):
        alias = es.indices.get_alias(name=es.index_name)
        previous_indices = alias.keys()
        if index_name not in previous_indices:
            es.indices.put_alias(index=index_name, name=es.index_name)
        for index in previous_indices:
            if index != index_name:
                es.indices.delete_alias(index=index, name=es.index_name)
                if delete:
                    es.indices.delete(index=index)
    else:
        es.indices.put_alias(index=index_name, name=es.index_name)
480539
protected function __create(array $data, $index, $type, $id = null, array $parameters = []) {
        $parameters+=["api" => "create"];
        $api = strtolower($parameters["api"]) == "index" ? "index" : "create";
        unset($parameters["api"]);
        $result = $this->client->$api([
            'index' => $index,
            'type' => $type,
            'body' => $data] + ($id ? ['id' => $id] : []) + $parameters);
        if (array_key_exists('_shards', $result) && array_key_exists('failed', $result['_shards']) && $result['_shards']['failed'] > 0) {
            throw new Exception('Failed to create the document. Serialized results: ' + json_encode($result));
        } else {
            $result = $this->__find($result['_index'], $result['_type'], $result['_id']);
        }
        return $result;
    }
113377
protected function createWriteAlias()
    {
        $configurator = $this->getIndexConfigurator();

        if (! in_array(Migratable::class, class_uses_recursive($configurator))) {
            return;
        }

        $indices = ElasticClient::indices();

        $existsPayload = (new RawPayload())
            ->set('name', $configurator->getWriteAlias())
            ->get();

        if ($indices->existsAlias($existsPayload)) {
            return;
        }

        $putPayload = (new IndexPayload($configurator))
            ->set('name', $configurator->getWriteAlias())
            ->get();

        $indices->putAlias($putPayload);

        $this->info(sprintf(
            'The %s alias for the %s index was created!',
            $configurator->getWriteAlias(),
            $configurator->getName()
        ));
    }
379349
def add_index_alias(es, index_name, alias_name):
    """"""

    es.indices.put_alias(index=index_name, name=terms_alias)
580996
public function handle(Client $client, $index, $type, $alias)
    {
        $mapping = $this->configurations->getMapping($alias, $type);

        if (!$mapping) {
            throw new \InvalidArgumentException();
        }

        $client
            ->getIndex($index)
            ->getType($type)
            ->setMapping($mapping)
        ;
    }
359311
public function handle(Client $client, $index)
    {
        $index = $client->getIndex($index);

        if (!$index->exists()) {
            throw new IndexNotFoundException($index);
        }

        $index->delete();
    }
1356850
public function createIndex(IndexEvent $event)
    {
        $data = $this->getClient()->indices()->create($event->getExtraData());

        $event->setExtraData($data);
    }
18189
public function createIndex($index, $configuration = null)
    {
        $body = $configuration !== null ? Json::encode($configuration) : null;

        return $this->db->put([$index], [], $body);
    }
140906
public function createQueryBuilder($alias, $indexBy = null)
    {
        return $this->em->createQueryBuilder()
            ->select($alias)
            ->from($this->entityName, $alias, $indexBy);
    }
168908
public function create($index, $body = null)
    {
        $request = $this->createRequestInstance(self::INDEX_CREATE, $index, null);

        if (null !== $body) {
            $request->setBody($body);
        }

        return $this->client->send($request);
    }
387235
public function getCreateIndexSQL(Index $index, $table)
    {
        if ($table instanceof Table) {
            $table = $table->getQuotedName($this);
        }
        $name    = $index->getQuotedName($this);
        $columns = $index->getColumns();

        if (count($columns) === 0) {
            throw new InvalidArgumentException("Incomplete definition. 'columns' required.");
        }

        if ($index->isPrimary()) {
            return $this->getCreatePrimaryKeySQL($index, $table);
        }

        $query  = 'CREATE ' . $this->getCreateIndexSQLFlags($index) . 'INDEX ' . $name . ' ON ' . $table;
        $query .= ' (' . $this->getIndexFieldDeclarationListSQL($index) . ')' . $this->getPartialIndexSQL($index);

        return $query;
    }
465038
protected void initializeClient(JestClient client, String indexName, String defaultIndexName) {
        try {
            client.execute(new Health.Builder().build());
            Action<JestResult> action = new IndicesExists.Builder(indexName).build();
            // There was occasions where a race occurred here when multiple threads try to
            // create the index simultaneously. This caused a non-fatal, but annoying, exception.
            synchronized(AbstractClientFactory.class) {
                JestResult result = client.execute(action);
                if (!result.isSucceeded()) {
                    createIndex(client, indexName, defaultIndexName + "-settings.json"); //$NON-NLS-1$
                }
            }
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }