<commit_before><?php

namespace Isswp101\Persimmon\Test;

use Carbon\Carbon;
use Elasticsearch\Common\Exceptions\Missing404Exception;
use Illuminate\Database\Eloquent\ModelNotFoundException;
use Illuminate\Support\Collection;
use Isswp101\Persimmon\Collection\ElasticsearchCollection;
use Isswp101\Persimmon\ElasticsearchModel;
use Isswp101\Persimmon\Model;
use Isswp101\Persimmon\QueryBuilder\Aggregations\TermsAggregation;
use Isswp101\Persimmon\QueryBuilder\Filters\IdsFilter;
use Isswp101\Persimmon\QueryBuilder\Filters\TermFilter;
use Isswp101\Persimmon\QueryBuilder\QueryBuilder;
use Isswp101\Persimmon\Test\Models\Product;

class BasicFeaturesTest extends BaseTestCase
{
    public function testPrepareIndex()
    {
        $index = Product::getIndex();
        $type = Product::getType();

        try {
            $this->es->indices()->delete(['index' => $index]);
        } catch (Missing404Exception $e) {
        }

        $this->es->indices()->create(['index' => $index]);

        $query = ['index' => $index, 'type' => $type, 'body' => ['query' => ['match_all' => []]]];
        $res = $this->es->search($query);
        $this->assertEquals(0, $res['hits']['total']);
    }

    public function testFill()
    {
        $p1 = new Product();
        $p1->id = 1;
        $p1->name = 'name';<commit_msg>sleep<commit_after><?php

namespace Isswp101\Persimmon\Test;

use Carbon\Carbon;
use Elasticsearch\Common\Exceptions\Missing404Exception;
use Illuminate\Database\Eloquent\ModelNotFoundException;
use Illuminate\Support\Collection;
use Isswp101\Persimmon\Collection\ElasticsearchCollection;
use Isswp101\Persimmon\ElasticsearchModel;
use Isswp101\Persimmon\Model;
use Isswp101\Persimmon\QueryBuilder\Aggregations\TermsAggregation;
use Isswp101\Persimmon\QueryBuilder\Filters\IdsFilter;
use Isswp101\Persimmon\QueryBuilder\Filters\TermFilter;
use Isswp101\Persimmon\QueryBuilder\QueryBuilder;
use Isswp101\Persimmon\Test\Models\Product;

class BasicFeaturesTest extends BaseTestCase
{
    public function testPrepareIndex()
    {
        $index = Product::getIndex();
        $type = Product::getType();

        try {
            $this->es->indices()->delete(['index' => $index]);
        } catch (Missing404Exception $e) {
        }

        sleep(2);

        $this->es->indices()->create(['index' => $index]);

        $query = ['index' => $index, 'type' => $type, 'body' => ['query' => ['match_all' => []]]];
        $res = $this->es->search($query);
        $this->assertEquals(0, $res['hits']['total']);
    }

    public function testFill()
    {
        $p1 = new Product();
        $p1->id = 1;
        $p1->name = 'name';
{'fraction_non_alphanumeric': 0.15300340007555724, 'fraction_numerical': 0.029089535323007176, 'mean_word_length': 3.754039497307002, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 39, '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': '636867', 'n_tokens_mistral': 870, 'n_tokens_neox': 836, 'n_words': 136}