<commit_before><?php

namespace Doctrine\Search\ElasticSearch;

use Doctrine\Search\Mapping\ClassMetadata;
use Doctrine\Search\SearchManager;
use Elastica\Exception\ResponseException;
use Elastica\Index;
use Elastica\Type;

class MappingManager {
    /** @var SearchManager */
    protected $sm;
    /** @var \Doctrine\Search\SearchClientInterface */
    protected $client;
    /** @var string */
    protected $env;

    public function __construct(SearchManager $sm, $env) {
        $this->sm = $sm;
        $this->client = $sm->getClient();
        $this->env = $env;
    }

    /**
     * Refreshes all the templates and mappings
     */
    public function update() {
        $this->updateTemplates();
        $this->updateMappings();
    }

    /**
     * Update existing templates
     */
    public function updateTemplates() {
        $metadatas = $this->sm->getMetadataFactory()->getAllMetadata();
        $indexToMetadatas = array();

        // Refresh the templates
        /** @var ClassMetadata $metadata */
        foreach ($metadatas as $metadata) {
                $indexToMetadatas[$metadata->index][] = $metadata;
        }

        if (! empty($indexToMetadatas)) {
            $this->client->createTemplates($indexToMetadatas);
        }<commit_msg>Fix the template update for blank type<commit_after><?php

namespace Doctrine\Search\ElasticSearch;

use Doctrine\Search\Mapping\ClassMetadata;
use Doctrine\Search\SearchManager;
use Elastica\Exception\ResponseException;
use Elastica\Index;
use Elastica\Type;

class MappingManager {
    /** @var SearchManager */
    protected $sm;
    /** @var \Doctrine\Search\SearchClientInterface */
    protected $client;
    /** @var string */
    protected $env;

    public function __construct(SearchManager $sm, $env) {
        $this->sm = $sm;
        $this->client = $sm->getClient();
        $this->env = $env;
    }

    /**
     * Refreshes all the templates and mappings
     */
    public function update() {
        $this->updateTemplates();
        $this->updateMappings();
    }

    /**
     * Update existing templates
     */
    public function updateTemplates() {
        $metadatas = $this->sm->getMetadataFactory()->getAllMetadata();
        $indexToMetadatas = array();

        // Refresh the templates
        /** @var ClassMetadata $metadata */
        foreach ($metadatas as $metadata) {
            if ($metadata->index && $metadata->type) {
                $indexToMetadatas[$metadata->index][] = $metadata;
            }
        }

        if (! empty($indexToMetadatas)) {
            $this->client->createTemplates($indexToMetadatas);
        }
{'fraction_non_alphanumeric': 0.13505311077389984, 'fraction_numerical': 0.0, 'mean_word_length': 2.50199203187251, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6032460', 'n_tokens_mistral': 766, 'n_tokens_neox': 740, 'n_words': 157}