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']));
    }
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']));
    }
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' ] ) ) ; }
Creates an index template in elastic search.

@link https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-templates.html

@param Client $client
@param string $name
Creates an index template in elastic search .