improve characters query and indexing

This commit is contained in:
Irfan 2021-06-29 01:44:21 +05:00
parent 6e9b534ccf
commit 7919b49c60
2 changed files with 19 additions and 6 deletions

View File

@ -34,9 +34,11 @@ class SearchQueryBuilderCharacter implements SearchQueryBuilderInterface
if (!empty($query) && is_null($letter)) {
$results = $results
->where('name', 'like', "%{$query}%")
->orWhere('name_kanji', 'like', "%{$query}%")
->orWhere('nicknames', 'like', "%{$query}%");
->whereRaw([
'$text' => [
'$search' => $query
]
]);
}
if (!is_null($letter)) {

View File

@ -23,9 +23,20 @@ class CreateCharactersTable extends Migration
$table->index('nicknames');
$table->integer('member_favorites')->index('member_favorites');
$table->string('about')->nullable();
$table->index('animeography');
$table->index('mangaography');
$table->index('voice_actors');
$table->index([
'name' => 'text',
'nicknames' => 'text',
],
'characters_search_index',
null,
[
'weights' => [
'name' => 50,
'nicknames' => 10,
],
'name' => 'characters_search_index'
]
);
});
}