Files
animethemes-server/elastic/migrations/2020_12_21_225415_create_anime_index.php
2026-04-17 13:54:35 -03:00

70 lines
1.8 KiB
PHP

<?php
declare(strict_types=1);
use App\Concerns\Elastic\ConfiguresTextAnalyzers;
use Elastic\Adapter\Indices\Mapping;
use Elastic\Adapter\Indices\Settings;
use Elastic\Migrations\Facades\Index;
use Elastic\Migrations\MigrationInterface;
final class CreateAnimeIndex implements MigrationInterface
{
use ConfiguresTextAnalyzers;
/**
* Run the migration.
*/
public function up(): void
{
Index::create('anime', function (Mapping $mapping, Settings $settings) {
$this->configureTextAnalyzers($settings);
$mapping->long('anime_id');
$mapping->date('created_at');
$mapping->text('name', [
'analyzer' => 'name_search',
'fields' => [
'keyword' => [
'type' => 'keyword',
],
],
]);
$mapping->long('season');
$mapping->long('format');
$mapping->text('slug', [
'fields' => [
'keyword' => [
'type' => 'keyword',
],
],
]);
$mapping->text('synonyms', [
'analyzer' => 'name_search',
'fields' => [
'keyword' => [
'type' => 'keyword',
],
],
]);
$mapping->text('synopsis', [
'fields' => [
'keyword' => [
'type' => 'keyword',
],
],
]);
$mapping->date('updated_at');
$mapping->long('year');
});
}
/**
* Reverse the migration.
*/
public function down(): void
{
Index::dropIfExists('anime');
}
}