Checks if an existing index is missing any custom normalizers
and if it is, updates settings to include them.

@param Index  $index
@param string $name
768126
protected function updateNormalizers(Index $index, string $name)
    {
        $settings = $index->getSettings();
        $customNormalizers = $this->getCustomNormalizers();
        $missingNormalizers = [];

        try {
            foreach ($customNormalizers as $id => $normalizer) {
                if (!$settings->get("analysis.normalizer.{$id}")) {
                    $missingNormalizers[$id] = $normalizer;
                }
            }
        } catch (\Throwable $e) {
            $this->logger->error(
                sprintf('Unable to read index [%s] and get normalizer settings.', $name),
                ['exception' => $e, 'index_name' => $name]
            );

            return;
        }

        if (empty($missingNormalizers)) {
            $this->logger->info(
                sprintf(
                    'Index [%s] has all custom normalizers [%s].',
                    $name,
                    implode(',', array_keys($customNormalizers))
                )
            );

            return;
        }

        $this->logger->warning(
            sprintf(
                'Closing index [%s] to add custom normalizers [%s].',
                $name,
                implode(',', array_keys($missingNormalizers))
            )
        );

        try {
            $index->close();
            $index->setSettings(['analysis' => ['normalizer' => $missingNormalizers]]);
            $index->open();
        } catch (\Throwable $e) {
            $this->logger->error(
                sprintf('Unable to close index [%s] and update normalizer settings.', $name),
                ['exception' => $e, 'index_name' => $name]
            );

            return;
        }

        $this->logger->info(sprintf('Successfully added missing normalizers to index [%s]', $name));
    }
8710
final public function removeColumn(string $name): Index
    {
        if (!$this->hasColumn($name)) {
            throw new InvalidArgumentException('Index not contains the column '.$name);
        }

        $this->columns = array_filter(
            $this->columns,
            function (IndexColumn $indexColumn) use ($name) {
                $column = $indexColumn->getColumn();

                return (bool) ($column::getName() !== $name);
            }
        );

        return $this;
    }
1023703
public function replaceByIndex($offset, $name = null)
    {
        if (!isset($this->elements[$offset])) {
            throw new OutOfBoundsException(sprintf('The offset %s is not within the property path', $offset));
        }

        if (null !== $name) {
            $this->elements[$offset] = $name;
        }

        $this->isIndex[$offset] = true;
    }
68429
public static function clean($name)
    {
        $index_prefix = Config::get('larasearch.elasticsearch.index_prefix', '');
        if ($index_prefix && !Str::startsWith($name, $index_prefix)) $name = $index_prefix . $name;

        $indices = self::getClient()->indices()->getAliases();
        foreach ($indices as $index => $value)
        {
            if (empty($value['aliases']) && preg_match("/^${name}_\\d{14,17}$/", $index))
            {
                self::getClient()->indices()->delete(['index' => $index]);
            }
        }
    }
366347
public function set($key, $value, $index_name = null)
	{
		list($index_name, $key) = $this->normalizeAccessKey($key, $index_name);

		$this->items[$index_name][$key] = $value;
	}
3141
public function addChild($index) {
		foreach($this->children as $child) {
			if($child->getID() == $index) return;
		}
		$this->children[] = $this->reflector->getBlockByID($index);
	}
878320
def index_template_absent(name):
    '''
    
    '''

    ret = {'name': name, 'changes': {}, 'result': True, 'comment': ''}

    try:
        index_template = __salt__['elasticsearch.index_template_get'](name=name)
        if index_template and name in index_template:
            if __opts__['test']:
                ret['comment'] = 'Index template {0} will be removed'.format(name)
                ret['changes']['old'] = index_template[name]
                ret['result'] = None
            else:
                ret['result'] = __salt__['elasticsearch.index_template_delete'](name=name)
                if ret['result']:
                    ret['comment'] = 'Successfully removed index template {0}'.format(name)
                    ret['changes']['old'] = index_template[name]
                else:
                    ret['comment'] = 'Failed to remove index template {0} for unknown reasons'.format(name)
        else:
            ret['comment'] = 'Index template {0} is already absent'.format(name)
    except Exception as err:
        ret['result'] = False
        ret['comment'] = six.text_type(err)

    return ret
729932
final public function updateTemplate(Client $client, string $name): void
    {
        $fakeIndex = new Index($client, $name);
        $mappings = [];
        foreach ($this->createMappings() as $typeName => $mapping) {
            $mapping->setType(new Type($fakeIndex, $typeName));
            $mappings[$typeName] = $mapping->toArray();
        }

        $params = [
            'template' => '*' . $name . '*',
            'settings' => [
                'number_of_shards'   => 1,
                'number_of_replicas' => 1,
                'index'              => [
                    'analysis' => [
                        'analyzer'   => $this->getCustomAnalyzers(),
                        'normalizer' => $this->getCustomNormalizers(),
                    ],
                ],
            ],
            'mappings' => $mappings,
        ];

        $this->beforeUpdateTemplate($params);
        $template = new IndexTemplate($client, $name);
        $template->create($params);
        $this->logger->info(sprintf('Successfully created index template [%s].', $params['template']));
    }
557828
protected function applyDefaultColumns($index)
    {
        $column = $this->loadColumnSchema([
            'Field' => 'id',
            'Type' => 'bigint',
        ]);
        $index->columns[$column->name] = $column;
        $index->primaryKey = 'id';
    }
1165388
public function hasIndex($name)
    {
        foreach ($this->indices as $idx) {
            if ($idx->getName() == $name) {
                return true;
            }
        }

        return false;
    }
674450
public static function remove($index)
    {
        if (isset(self::$views[$index])) {
            self::$views[$index] = null;
        }
    }
690775
public function removeIndex($name)
    {
        //check if we have a index with this name already, then delete it
        foreach ($this->indices as $n => $idx) {
            if ($idx->getName() == $name) {
                unset($this->indices[$n]);

                return;
            }
        }
    }
922553
public function update($index, $data) {
        if (!$data instanceof Record) {
            $data = new Record(Utils::toArray($data));
        }
        $this->getFormat()->update($index, $data);
        // update buffer to reflect current changes
        if (isset($this->buffer[$index])) {
            $this->buffer[$index] = $data;
        }
    }
95098
public function addSecondaryIndex(Index $index)
    {
        if ($this->isEmbeddedDocument) {
            throw MappingException::embeddedDocumentsNotIndexable($this->getName());
        }

        if (isset($this->secondaryIndexes[$index->getName()])) {
            throw MappingException::indexExists($this->getName(), $index->getName());
        }

        $this->secondaryIndexes[$index->getName()] = $index;
    }
332002
public function setIndex($index)
    {
        $this->index = $index;

        $this->setIndexClean(
            str_replace('.', '', $index)
        );

        return $this;
    }
1115476
public function rename($index, $newName)
    {
        if (!isset($this->names[$index])) {
            return false;
        }
        if ($this->names[$index] === $newName) {
            return false;
        }
        $this->context->getMappings();
        $this->names[$index] = $newName;
        $this->indexes = array_flip($this->names);
        $this->onRename($index, $newName);
        return true;
    }
591612
public function get($name, $index = 0)
    {
        $name = strtolower($name);

        if (func_num_args() < 2) {
            if ($this->has($name)) {
                $values = array_values($this->headers[$name]);

                return array_shift($values);
            }
        } else {
            if ($this->has($name, $index)) {
                return $this->headers[$name][$index];
            }
        }
    }