mirror of
https://github.com/jikan-me/jikan-rest.git
synced 2025-02-20 11:23:35 +08:00
improve characters query and indexing
This commit is contained in:
parent
6e9b534ccf
commit
7919b49c60
@ -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)) {
|
||||
|
@ -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'
|
||||
]
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user