Update item search with better fallbacks and nicknames (#122)
* Add migrations for nicknames * Rename migrations to be after last migration * Migrate database * Update search in models * Search against nickname columns * Add dictionary search to EN search so its not only trigrams
This commit is contained in:
parent
0ccbb7ecfe
commit
1646f3d555
7 changed files with 37 additions and 7 deletions
|
|
@ -14,15 +14,19 @@ class Character < ApplicationRecord
|
|||
}
|
||||
|
||||
pg_search_scope :en_search,
|
||||
against: :name_en,
|
||||
against: %i[name_en nicknames_en],
|
||||
using: {
|
||||
tsearch: {
|
||||
prefix: true,
|
||||
dictionary: 'simple'
|
||||
},
|
||||
trigram: {
|
||||
threshold: 0.18
|
||||
}
|
||||
}
|
||||
|
||||
pg_search_scope :ja_search,
|
||||
against: :name_jp,
|
||||
against: %i[name_jp nicknames_jp],
|
||||
using: {
|
||||
tsearch: {
|
||||
prefix: true,
|
||||
|
|
|
|||
|
|
@ -14,15 +14,19 @@ class Summon < ApplicationRecord
|
|||
}
|
||||
|
||||
pg_search_scope :en_search,
|
||||
against: :name_en,
|
||||
against: %i[name_en nicknames_en],
|
||||
using: {
|
||||
tsearch: {
|
||||
prefix: true,
|
||||
dictionary: 'simple'
|
||||
},
|
||||
trigram: {
|
||||
threshold: 0.18
|
||||
}
|
||||
}
|
||||
|
||||
pg_search_scope :ja_search,
|
||||
against: :name_jp,
|
||||
against: %i[name_jp nicknames_jp],
|
||||
using: {
|
||||
tsearch: {
|
||||
prefix: true,
|
||||
|
|
|
|||
|
|
@ -14,15 +14,19 @@ class Weapon < ApplicationRecord
|
|||
}
|
||||
|
||||
pg_search_scope :en_search,
|
||||
against: :name_en,
|
||||
against: %i[name_en nicknames_en],
|
||||
using: {
|
||||
tsearch: {
|
||||
prefix: true,
|
||||
dictionary: 'simple'
|
||||
},
|
||||
trigram: {
|
||||
threshold: 0.18
|
||||
}
|
||||
}
|
||||
|
||||
pg_search_scope :ja_search,
|
||||
against: :name_jp,
|
||||
against: %i[name_jp nicknames_jp],
|
||||
using: {
|
||||
tsearch: {
|
||||
prefix: true,
|
||||
|
|
|
|||
6
db/migrate/20230820113800_add_nicknames_to_characters.rb
Normal file
6
db/migrate/20230820113800_add_nicknames_to_characters.rb
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
class AddNicknamesToCharacters < ActiveRecord::Migration[7.0]
|
||||
def change
|
||||
add_column :characters, :nicknames_en, :string, array: true, default: [], null: false, if_not_exists: true
|
||||
add_column :characters, :nicknames_jp, :string, array: true, default: [], null: false, if_not_exists: true
|
||||
end
|
||||
end
|
||||
6
db/migrate/20230820113810_add_nicknames_to_summons.rb
Normal file
6
db/migrate/20230820113810_add_nicknames_to_summons.rb
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
class AddNicknamesToSummons < ActiveRecord::Migration[7.0]
|
||||
def change
|
||||
add_column :summons, :nicknames_en, :string, array: true, default: [], null: false, if_not_exists: true
|
||||
add_column :summons, :nicknames_jp, :string, array: true, default: [], null: false, if_not_exists: true
|
||||
end
|
||||
end
|
||||
6
db/migrate/20230820113900_add_nicknames_to_weapons.rb
Normal file
6
db/migrate/20230820113900_add_nicknames_to_weapons.rb
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
class AddNicknamesToWeapons < ActiveRecord::Migration[7.0]
|
||||
def change
|
||||
add_column :weapons, :nicknames_en, :string, array: true, default: [], null: false, if_not_exists: true
|
||||
add_column :weapons, :nicknames_jp, :string, array: true, default: [], null: false, if_not_exists: true
|
||||
end
|
||||
end
|
||||
|
|
@ -10,7 +10,7 @@
|
|||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema[7.0].define(version: 2023_08_20_045019) do
|
||||
ActiveRecord::Schema[7.0].define(version: 2023_08_20_113900) do
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "btree_gin"
|
||||
enable_extension "pg_trgm"
|
||||
|
|
|
|||
Loading…
Reference in a new issue