<commit_before><?php

namespace FOQ\ElasticaBundle;

/**
 * Deletes and recreates indexes
 **/
class Reseter
{
    protected $indexManager;

    public function __construct(IndexManager $indexManager)
    {
        $this->indexManager = $indexManager;
    }

    /**
     * Resets all indexes
     *
     * @return null
     **/
    public function reset()
    {
        foreach ($this->indexManager->getAllIndexes() as $index) {
            $index->delete();
            $index->create();
        }
    }
}<commit_msg>Fix issue in reseter when an index does not exist yet<commit_after><?php

namespace FOQ\ElasticaBundle;

use Elastica_Exception_Response;

/**
 * Deletes and recreates indexes
 **/
class Reseter
{
    protected $indexManager;

    public function __construct(IndexManager $indexManager)
    {
        $this->indexManager = $indexManager;
    }

    /**
     * Resets all indexes
     *
     * @return null
     **/
    public function reset()
    {
        foreach ($this->indexManager->getAllIndexes() as $index) {
            try {
                $index->delete();
            } catch (Elastica_Exception_Response $e) {
                // The index does not exist
            }
            $index->create();
        }
    }
}
{'fraction_non_alphanumeric': 0.11547714514835605, 'fraction_numerical': 0.0, 'mean_word_length': 2.029126213592233, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 13, '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': '4169828', 'n_tokens_mistral': 370, 'n_tokens_neox': 358, 'n_words': 83}