diff --git a/app/models/anime.rb b/app/models/anime.rb index 4302f4136..d118ccc50 100644 --- a/app/models/anime.rb +++ b/app/models/anime.rb @@ -84,13 +84,12 @@ def self.fuzzy_find(title) end def self.rails_admin_search(keyword) - where(id: TypesenseAnimeIndex.search( + find(TypesenseAnimeIndex.search( query: keyword, query_by: { 'canonical_title' => 100, 'titles.*' => 90, - 'alternative_titles' => 90, - 'descriptions.*' => 80 + 'alternative_titles' => 90 } ).sort({ '_text_match(buckets: 6)' => 'desc', diff --git a/app/models/manga.rb b/app/models/manga.rb index 7e6c20400..c61953f8d 100644 --- a/app/models/manga.rb +++ b/app/models/manga.rb @@ -47,18 +47,18 @@ def self.unit_class end def self.rails_admin_search(keyword) - where(id: TypesenseMangaIndex.search( + find(TypesenseMangaIndex.search( query: keyword, query_by: { 'canonical_title' => 100, 'titles.*' => 90, - 'alternative_titles' => 90, - 'descriptions.*' => 80 + 'alternative_titles' => 90 } ).sort({ '_text_match(buckets: 6)' => 'desc', 'user_count' => 'desc' - }).include_fields(:id).load.hits.map { |res| res.document['id'] }) end + }).include_fields(:id).load.hits.map { |res| res.document['id'] }) + end def self.typesense_index TypesenseMangaIndex