<commit_before><?php

namespace Ulff\ElasticsearchPhpClientBundle\Service;

use Ulff\ElasticsearchPhpClientBundle\Client\ElasticSearchPhpClient;

class ElasticSearchPurger
{
    /**
     * @var ElasticSearchPhpClient
     */
    private $client;

    /**
     * @param ElasticSearchPhpClient $client
     */
    public function __construct(ElasticSearchPhpClient $client)
    {
        $this->client = $client;
    }

    /**
     * @param string $indexName
     */
    public function purgeIndex($indexName)
    {
        if($this->client->getNativeClient()->indices()->exists(['index' => $indexName])) {
            $this->client->getNativeClient()->indices()->delete(['index' => $indexName]);
        }
        $this->client->getNativeClient()->indices()->create(['index' => $indexName]);
    }
}<commit_msg>cluster health: added wait_for_status<commit_after><?php

namespace Ulff\ElasticsearchPhpClientBundle\Service;

use Ulff\ElasticsearchPhpClientBundle\Client\ElasticSearchPhpClient;

class ElasticSearchPurger
{
    /**
     * @var ElasticSearchPhpClient
     */
    private $client;

    /**
     * @param ElasticSearchPhpClient $client
     */
    public function __construct(ElasticSearchPhpClient $client)
    {
        $this->client = $client;
    }

    /**
     * @param string $indexName
     */
    public function purgeIndex($indexName)
    {
        if($this->client->getNativeClient()->indices()->exists(['index' => $indexName])) {
            $this->client->getNativeClient()->indices()->delete(['index' => $indexName]);
        }
        $this->client->getNativeClient()->indices()->create(['index' => $indexName]);
        $this->client->getNativeClient()->cluster()->health([
            'wait_for_status' => 'yellow'
        ]);
    }
}
{'fraction_non_alphanumeric': 0.1583427922814983, 'fraction_numerical': 0.0, 'mean_word_length': 3.0904872389791183, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 40, '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': '6515948', 'n_tokens_mistral': 517, 'n_tokens_neox': 512, 'n_words': 70}