mirror of
https://github.com/AnimeThemes/animethemes-server.git
synced 2026-07-11 01:24:46 +02:00
feat: synonyms rework (#1109)
This commit is contained in:
@@ -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');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user