diff --git a/app/Filament/RelationManagers/User/SubmissionStageRelationManager.php b/app/Filament/RelationManagers/User/SubmissionStageRelationManager.php index 03c236579..bb5c7056b 100644 --- a/app/Filament/RelationManagers/User/SubmissionStageRelationManager.php +++ b/app/Filament/RelationManagers/User/SubmissionStageRelationManager.php @@ -7,7 +7,6 @@ namespace App\Filament\RelationManagers\User; use App\Filament\RelationManagers\BaseRelationManager; use App\Filament\Resources\BaseResource; use App\Filament\Resources\User\Submission\SubmissionStageResource; -use App\Models\User\Submission\SubmissionStage; use Filament\Tables\Table; abstract class SubmissionStageRelationManager extends BaseRelationManager diff --git a/app/Filament/RelationManagers/Wiki/Anime/ThemeRelationManager.php b/app/Filament/RelationManagers/Wiki/Anime/ThemeRelationManager.php index 48d4d4113..c518efadd 100644 --- a/app/Filament/RelationManagers/Wiki/Anime/ThemeRelationManager.php +++ b/app/Filament/RelationManagers/Wiki/Anime/ThemeRelationManager.php @@ -7,7 +7,6 @@ namespace App\Filament\RelationManagers\Wiki\Anime; use App\Filament\RelationManagers\BaseRelationManager; use App\Filament\Resources\BaseResource; use App\Filament\Resources\Wiki\Anime\ThemeResource; -use App\Models\Wiki\Anime\AnimeTheme; use Filament\Tables\Table; abstract class ThemeRelationManager extends BaseRelationManager diff --git a/app/Models/Wiki/Anime.php b/app/Models/Wiki/Anime.php index fcd27d557..66f71c12f 100644 --- a/app/Models/Wiki/Anime.php +++ b/app/Models/Wiki/Anime.php @@ -167,7 +167,7 @@ class Anime extends BaseModel implements Auditable, HasImages, HasResources, Has public function toSearchableArray(): array { $array = $this->attributesToArray(); - $array['synonyms'] = $this->synonyms->toArray(); + $array['synonyms'] = $this->synonyms->map(fn (Synonym $synonym) => $synonym->text)->all(); return $array; } diff --git a/app/Scout/Elasticsearch/Api/Query/Wiki/Anime/Theme/EntryQuery.php b/app/Scout/Elasticsearch/Api/Query/Wiki/Anime/Theme/EntryQuery.php index be7339f1c..55dfdd033 100644 --- a/app/Scout/Elasticsearch/Api/Query/Wiki/Anime/Theme/EntryQuery.php +++ b/app/Scout/Elasticsearch/Api/Query/Wiki/Anime/Theme/EntryQuery.php @@ -43,7 +43,7 @@ class EntryQuery extends ElasticQuery [ 'bool' => [ 'boost' => 0.5 * 0.85, - 'should' => $this->createNestedTextQuery('theme.anime.synonyms', 'text', $criteria->getTerm()), + 'should' => $this->createNestedTextQuery('theme.anime', 'synonyms', $criteria->getTerm()), ], ], ], @@ -59,7 +59,6 @@ class EntryQuery extends ElasticQuery ], [ 'bool' => [ - 'boost' => 0.85, 'should' => $this->createTextQuery('anime_slug', $criteria->getTerm()), ], ], diff --git a/app/Scout/Elasticsearch/Api/Query/Wiki/Anime/ThemeQuery.php b/app/Scout/Elasticsearch/Api/Query/Wiki/Anime/ThemeQuery.php index a97c2aa22..eca940b98 100644 --- a/app/Scout/Elasticsearch/Api/Query/Wiki/Anime/ThemeQuery.php +++ b/app/Scout/Elasticsearch/Api/Query/Wiki/Anime/ThemeQuery.php @@ -43,16 +43,32 @@ class ThemeQuery extends ElasticQuery [ 'bool' => [ 'boost' => 0.9 * 0.85, - 'should' => $this->createNestedTextQuery('anime.synonyms', 'text', $criteria->getTerm()), + 'should' => $this->createNestedTextQuery('anime', 'synonyms', $criteria->getTerm()), ], ], ], ], ], [ - 'bool' => [ - 'boost' => 0.85, - 'should' => $this->createTextQuery('slug', $criteria->getTerm()), + 'dis_max' => [ + 'queries' => [ + [ + 'bool' => [ + 'should' => $this->createTextQuery('slug', $criteria->getTerm()), + ], + ], + [ + 'bool' => [ + 'should' => $this->createTextQuery('anime_slug', $criteria->getTerm()), + ], + ], + [ + 'bool' => [ + 'boost' => 0.7, + 'should' => $this->createTextQuery('synonym_slug', $criteria->getTerm()), + ] + ], + ], ], ], ], diff --git a/app/Scout/Elasticsearch/Api/Query/Wiki/AnimeQuery.php b/app/Scout/Elasticsearch/Api/Query/Wiki/AnimeQuery.php index 4f5838845..03216251f 100644 --- a/app/Scout/Elasticsearch/Api/Query/Wiki/AnimeQuery.php +++ b/app/Scout/Elasticsearch/Api/Query/Wiki/AnimeQuery.php @@ -28,7 +28,7 @@ class AnimeQuery extends ElasticQuery [ 'bool' => [ 'boost' => 0.85, - 'should' => $this->createNestedTextQuery('synonyms', 'text', $criteria->getTerm()), + 'should' => $this->createTextQuery('synonyms', 'text'), ], ], ], diff --git a/app/Scout/Elasticsearch/Api/Query/Wiki/SeriesQuery.php b/app/Scout/Elasticsearch/Api/Query/Wiki/SeriesQuery.php index 13b08812a..e29c6661a 100644 --- a/app/Scout/Elasticsearch/Api/Query/Wiki/SeriesQuery.php +++ b/app/Scout/Elasticsearch/Api/Query/Wiki/SeriesQuery.php @@ -26,10 +26,7 @@ class SeriesQuery extends ElasticQuery [ 'bool' => [ 'boost' => 0.6, - 'should' => $this->createNestedQuery( - 'anime', - $this->createNestedTextQuery('anime.synonyms', 'text', $criteria->getTerm()) - ), + 'should' => $this->createNestedTextQuery('anime', 'synonyms', $criteria->getTerm()), ], ], ], diff --git a/app/Scout/Elasticsearch/Api/Query/Wiki/VideoQuery.php b/app/Scout/Elasticsearch/Api/Query/Wiki/VideoQuery.php index 9eb2c6d0b..eb1cc0091 100644 --- a/app/Scout/Elasticsearch/Api/Query/Wiki/VideoQuery.php +++ b/app/Scout/Elasticsearch/Api/Query/Wiki/VideoQuery.php @@ -60,14 +60,14 @@ class VideoQuery extends ElasticQuery ], [ 'bool' => [ - 'boost' => 0.5, + 'boost' => 0.8, 'should' => $this->createNestedTextQuery('entries.theme.anime', 'name', $criteria->getTerm()), ], ], [ 'bool' => [ - 'boost' => 0.5 * 0.85, - 'should' => $this->createNestedTextQuery('entries.theme.anime.synonyms', 'text', $criteria->getTerm()), + 'boost' => 0.8 * 0.85, + 'should' => $this->createNestedTextQuery('entries.theme.anime', 'synonyms', $criteria->getTerm()), ], ], ], diff --git a/elastic/migrations/2020_12_21_225415_create_anime_index.php b/elastic/migrations/2020_12_21_225415_create_anime_index.php index cf77c1fcc..7e8fdd2ce 100644 --- a/elastic/migrations/2020_12_21_225415_create_anime_index.php +++ b/elastic/migrations/2020_12_21_225415_create_anime_index.php @@ -39,30 +39,12 @@ final class CreateAnimeIndex implements MigrationInterface ], ], ]); - $mapping->nested('synonyms', [ - 'properties' => [ - 'synonymable_type' => [ + $mapping->text('synonyms', [ + 'analyzer' => 'name_search', + 'fields' => [ + 'keyword' => [ 'type' => 'keyword', ], - 'synonymable_id' => [ - 'type' => 'long', - ], - 'created_at' => [ - 'type' => 'date', - ], - 'synonym_id' => [ - 'type' => 'long', - ], - 'text' => [ - 'type' => 'text', - 'analyzer' => 'name_search', - ], - 'type' => [ - 'type' => 'long', - ], - 'updated_at' => [ - 'type' => 'date', - ], ], ]); $mapping->text('synopsis', [ diff --git a/elastic/migrations/2020_12_22_034505_create_entry_index.php b/elastic/migrations/2020_12_22_034505_create_entry_index.php index ce6350d0f..545b56427 100644 --- a/elastic/migrations/2020_12_22_034505_create_entry_index.php +++ b/elastic/migrations/2020_12_22_034505_create_entry_index.php @@ -62,34 +62,6 @@ final class CreateEntryIndex implements MigrationInterface 'slug' => [ 'type' => 'text', ], - 'synonyms' => [ - 'type' => 'nested', - 'properties' => [ - 'synonymable_type' => [ - 'type' => 'keyword', - ], - 'synonymable_id' => [ - 'type' => 'long', - ], - 'created_at' => [ - 'type' => 'date', - ], - 'synonym_id' => [ - 'type' => 'long', - ], - 'text' => [ - 'type' => 'text', - 'copy_to' => ['synonym_slug'], - 'analyzer' => 'name_search', - ], - 'type' => [ - 'type' => 'long', - ], - 'updated_at' => [ - 'type' => 'date', - ], - ], - ], 'synopsis' => [ 'type' => 'text', ], @@ -99,6 +71,16 @@ final class CreateEntryIndex implements MigrationInterface 'year' => [ 'type' => 'long', ], + 'synonyms' => [ + 'type' => 'text', + 'analyzer' => 'name_search', + 'copy_to' => ['synonym_slug'], + 'fields' => [ + 'keyword' => [ + 'type' => 'keyword', + ], + ], + ], ], ], 'anime_id' => [ diff --git a/elastic/migrations/2020_12_22_034544_create_series_index.php b/elastic/migrations/2020_12_22_034544_create_series_index.php index e4ab73b1a..fb6225a06 100644 --- a/elastic/migrations/2020_12_22_034544_create_series_index.php +++ b/elastic/migrations/2020_12_22_034544_create_series_index.php @@ -57,34 +57,6 @@ final class CreateSeriesIndex implements MigrationInterface 'slug' => [ 'type' => 'text', ], - 'synonyms' => [ - 'type' => 'nested', - 'properties' => [ - 'synonymable_type' => [ - 'type' => 'keyword', - ], - 'synonymable_id' => [ - 'type' => 'long', - ], - 'created_at' => [ - 'type' => 'date', - ], - 'synonym_id' => [ - 'type' => 'long', - ], - 'text' => [ - 'type' => 'text', - 'copy_to' => ['synonym_slug'], - 'analyzer' => 'name_search', - ], - 'type' => [ - 'type' => 'long', - ], - 'updated_at' => [ - 'type' => 'date', - ], - ], - ], 'synopsis' => [ 'type' => 'text', ], @@ -94,10 +66,18 @@ final class CreateSeriesIndex implements MigrationInterface 'year' => [ 'type' => 'long', ], + 'synonyms' => [ + 'type' => 'text', + 'analyzer' => 'name_search', + 'fields' => [ + 'keyword' => [ + 'type' => 'keyword', + ], + ], + ], ], ]); $mapping->text('anime_slug'); - $mapping->text('synonym_slug'); }); } diff --git a/elastic/migrations/2020_12_22_034557_create_theme_index.php b/elastic/migrations/2020_12_22_034557_create_theme_index.php index da44a7d05..536c7b818 100644 --- a/elastic/migrations/2020_12_22_034557_create_theme_index.php +++ b/elastic/migrations/2020_12_22_034557_create_theme_index.php @@ -39,34 +39,6 @@ final class CreateThemeIndex implements MigrationInterface 'slug' => [ 'type' => 'text', ], - 'synonyms' => [ - 'type' => 'nested', - 'properties' => [ - 'synonymable_type' => [ - 'type' => 'keyword', - ], - 'synonymable_id' => [ - 'type' => 'long', - ], - 'created_at' => [ - 'type' => 'date', - ], - 'synonym_id' => [ - 'type' => 'long', - ], - 'text' => [ - 'type' => 'text', - 'copy_to' => ['synonym_slug'], - 'analyzer' => 'name_search', - ], - 'type' => [ - 'type' => 'long', - ], - 'updated_at' => [ - 'type' => 'date', - ], - ], - ], 'synopsis' => [ 'type' => 'text', ], @@ -76,6 +48,16 @@ final class CreateThemeIndex implements MigrationInterface 'year' => [ 'type' => 'long', ], + 'synonyms' => [ + 'type' => 'text', + 'analyzer' => 'name_search', + 'copy_to' => ['synonym_slug'], + 'fields' => [ + 'keyword' => [ + 'type' => 'keyword', + ], + ], + ], ], ]); $mapping->long('anime_id'); diff --git a/elastic/migrations/2020_12_22_034601_create_video_index.php b/elastic/migrations/2020_12_22_034601_create_video_index.php index 1d6690705..0206db763 100644 --- a/elastic/migrations/2020_12_22_034601_create_video_index.php +++ b/elastic/migrations/2020_12_22_034601_create_video_index.php @@ -73,34 +73,6 @@ final class CreateVideoIndex implements MigrationInterface 'slug' => [ 'type' => 'text', ], - 'synonyms' => [ - 'type' => 'nested', - 'properties' => [ - 'synonymable_type' => [ - 'type' => 'keyword', - ], - 'synonymable_id' => [ - 'type' => 'long', - ], - 'created_at' => [ - 'type' => 'date', - ], - 'synonym_id' => [ - 'type' => 'long', - ], - 'text' => [ - 'type' => 'text', - 'copy_to' => ['synonym_slug'], - 'analyzer' => 'name_search', - ], - 'type' => [ - 'type' => 'long', - ], - 'updated_at' => [ - 'type' => 'date', - ], - ], - ], 'synopsis' => [ 'type' => 'text', ], @@ -110,6 +82,16 @@ final class CreateVideoIndex implements MigrationInterface 'year' => [ 'type' => 'long', ], + 'synonyms' => [ + 'type' => 'text', + 'analyzer' => 'name_search', + 'copy_to' => ['synonym_slug'], + 'fields' => [ + 'keyword' => [ + 'type' => 'keyword', + ], + ], + ], ], ], 'anime_id' => [