Files
animethemes-server/elastic/migrations/2020_12_22_033019_create_artist_index.php
2026-03-09 14:52:16 -03:00

75 lines
2.0 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 CreateArtistIndex implements MigrationInterface
{
use ConfiguresTextAnalyzers;
/**
* Run the migration.
*/
public function up(): void
{
Index::createIfNotExists('artists', function (Mapping $mapping, Settings $settings) {
$this->configureTextAnalyzers($settings);
$mapping->long('artist_id');
$mapping->date('created_at');
$mapping->text('name', [
'analyzer' => 'name_search',
'fields' => [
'keyword' => [
'type' => 'keyword',
],
],
]);
$mapping->text('slug', [
'fields' => [
'keyword' => [
'type' => 'keyword',
],
],
]);
$mapping->text('information', [
'fields' => [
'keyword' => [
'type' => 'keyword',
],
],
]);
$mapping->text('as', [
'analyzer' => 'name_search',
'fields' => [
'keyword' => [
'type' => 'keyword',
],
],
]);
$mapping->text('synonyms', [
'analyzer' => 'name_search',
'fields' => [
'keyword' => [
'type' => 'keyword',
],
],
]);
$mapping->date('updated_at');
});
}
/**
* Reverse the migration.
*/
public function down(): void
{
Index::dropIfExists('artists');
}
}