feat: synonyms rework (#1109)

This commit is contained in:
Kyrch
2026-02-18 20:26:46 -03:00
committed by GitHub
parent e4179cf312
commit b66c5cb3da
155 changed files with 2021 additions and 1269 deletions
@@ -41,7 +41,10 @@ final class CreateAnimeIndex implements MigrationInterface
]);
$mapping->nested('synonyms', [
'properties' => [
'anime_id' => [
'synonymable_type' => [
'type' => 'keyword',
],
'synonymable_id' => [
'type' => 'long',
],
'created_at' => [
@@ -65,7 +65,10 @@ final class CreateEntryIndex implements MigrationInterface
'synonyms' => [
'type' => 'nested',
'properties' => [
'anime_id' => [
'synonymable_type' => [
'type' => 'keyword',
],
'synonymable_id' => [
'type' => 'long',
],
'created_at' => [
@@ -60,7 +60,10 @@ final class CreateSeriesIndex implements MigrationInterface
'synonyms' => [
'type' => 'nested',
'properties' => [
'anime_id' => [
'synonymable_type' => [
'type' => 'keyword',
],
'synonymable_id' => [
'type' => 'long',
],
'created_at' => [
@@ -8,7 +8,7 @@ use Elastic\Adapter\Indices\Settings;
use Elastic\Migrations\Facades\Index;
use Elastic\Migrations\MigrationInterface;
final class CreateSynonymIndex implements MigrationInterface
final class CreateAnimeSynonymIndex implements MigrationInterface
{
use ConfiguresTextAnalyzers;
@@ -42,7 +42,10 @@ final class CreateThemeIndex implements MigrationInterface
'synonyms' => [
'type' => 'nested',
'properties' => [
'anime_id' => [
'synonymable_type' => [
'type' => 'keyword',
],
'synonymable_id' => [
'type' => 'long',
],
'created_at' => [
@@ -76,7 +76,10 @@ final class CreateVideoIndex implements MigrationInterface
'synonyms' => [
'type' => 'nested',
'properties' => [
'anime_id' => [
'synonymable_type' => [
'type' => 'keyword',
],
'synonymable_id' => [
'type' => 'long',
],
'created_at' => [
@@ -0,0 +1,47 @@
<?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 CreateSynonymIndex implements MigrationInterface
{
use ConfiguresTextAnalyzers;
/**
* Run the migration.
*/
public function up(): void
{
Index::createIfNotExists('synonyms', function (Mapping $mapping, Settings $settings) {
$this->configureTextAnalyzers($settings);
$mapping->keyword('synonymable_type');
$mapping->long('synonymable_id');
$mapping->date('created_at');
$mapping->long('synonym_id');
$mapping->text('text', [
'analyzer' => 'name_search',
'fields' => [
'keyword' => [
'type' => 'keyword',
],
],
]);
$mapping->long('type');
$mapping->date('updated_at');
});
}
/**
* Reverse the migration.
*/
public function down(): void
{
Index::dropIfExists('synonyms');
}
}