src/Search/Elastica/IndexManager.php
final public function createIndex(Client $client, SchemaQName $qname, array $context = []): Index
    {
        static $created = [];

        $indexName = $this->getIndexName($qname, $context);
        if (isset($created[$indexName])) {
            return $created[$indexName];
        }

        $index = $created[$indexName] = $client->getIndex($indexName);
        $type = $this->types[$qname->toString()] ?? $this->types['default'];
        $mapper = $this->getNodeMapper($qname);
        $settings = $this->filterIndexSettings($this->indexes[$type['index_name'] ?? 'default'], $qname, $context);
        unset($settings['fq_index_name']);

        try {
            if (!$index->exists()) {
                $settings['analysis'] = [
                    'analyzer'   => $mapper->getCustomAnalyzers(),
                    'normalizer' => $mapper->getCustomNormalizers(),
                ];

                $index->create($settings);
            }
        } catch (\Throwable $e) {
            throw new SearchOperationFailed(
                sprintf(
                    '%s while creating index [%s] for qname [%s].',
                    ClassUtils::getShortName($e),
                    $index->getName(),
                    $qname
                ),
                Code::INTERNAL,
                $e
            );
        }

        return $index;
    }
final public function createIndex(Client $client, SchemaQName $qname, array $context = []): Index
    {
        static $created = [];

        $indexName = $this->getIndexName($qname, $context);
        if (isset($created[$indexName])) {
            return $created[$indexName];
        }

        $index = $created[$indexName] = $client->getIndex($indexName);
        $type = $this->types[$qname->toString()] ?? $this->types['default'];
        $mapper = $this->getNodeMapper($qname);
        $settings = $this->filterIndexSettings($this->indexes[$type['index_name'] ?? 'default'], $qname, $context);
        unset($settings['fq_index_name']);

        try {
            if (!$index->exists()) {
                $settings['analysis'] = [
                    'analyzer'   => $mapper->getCustomAnalyzers(),
                    'normalizer' => $mapper->getCustomNormalizers(),
                ];

                $index->create($settings);
            }
        } catch (\Throwable $e) {
            throw new SearchOperationFailed(
                sprintf(
                    '%s while creating index [%s] for qname [%s].',
                    ClassUtils::getShortName($e),
                    $index->getName(),
                    $qname
                ),
                Code::INTERNAL,
                $e
            );
        }

        return $index;
    }
final public function createIndex ( Client $ client , SchemaQName $ qname , array $ context = [ ] ) : Index { static $ created = [ ] ; $ indexName = $ this -> getIndexName ( $ qname , $ context ) ; if ( isset ( $ created [ $ indexName ] ) ) { return $ created [ $ indexName ] ; } $ index = $ created [ $ indexName ] = $ client -> getIndex ( $ indexName ) ; $ type = $ this -> types [ $ qname -> toString ( ) ] ?? $ this -> types [ 'default' ] ; $ mapper = $ this -> getNodeMapper ( $ qname ) ; $ settings = $ this -> filterIndexSettings ( $ this -> indexes [ $ type [ 'index_name' ] ?? 'default' ] , $ qname , $ context ) ; unset ( $ settings [ 'fq_index_name' ] ) ; try { if ( ! $ index -> exists ( ) ) { $ settings [ 'analysis' ] = [ 'analyzer' => $ mapper -> getCustomAnalyzers ( ) , 'normalizer' => $ mapper -> getCustomNormalizers ( ) , ] ; $ index -> create ( $ settings ) ; } } catch ( \ Throwable $ e ) { throw new SearchOperationFailed ( sprintf ( '%s while creating index [%s] for qname [%s].' , ClassUtils :: getShortName ( $ e ) , $ index -> getName ( ) , $ qname ) , Code :: INTERNAL , $ e ) ; } return $ index ; }
Creates the index in ElasticSearch if it doesn't already exist.  It will NOT
perform an update as that requires the index be closed and reopened which
is not currently supported on AWS ElasticSearch service.

@param Client      $client  The Elastica client
@param SchemaQName $qname   QName used to derive the index name.
@param array       $context Data that helps the NCR Search decide where to read/write data from.

@return Index
Creates the index in ElasticSearch if it doesn t already exist . It will NOT perform an update as that requires the index be closed and reopened which is not currently supported on AWS ElasticSearch service .