Compare commits

...

4 commits

Author SHA1 Message Date
7acb7c190f Update search in models
* Search against nickname columns
* Add dictionary search to EN search so its not only trigrams
2023-08-20 00:42:21 -07:00
68d1e33827 Migrate database 2023-08-19 23:43:44 -07:00
d7d423260d Rename migrations to be after last migration 2023-08-19 23:42:21 -07:00
b801c99775 Add migrations for nicknames 2023-08-19 23:39:59 -07:00
7 changed files with 37 additions and 7 deletions

View file

@ -14,15 +14,19 @@ class Character < ApplicationRecord
} }
pg_search_scope :en_search, pg_search_scope :en_search,
against: :name_en, against: %i[name_en nicknames_en],
using: { using: {
tsearch: {
prefix: true,
dictionary: 'simple'
},
trigram: { trigram: {
threshold: 0.18 threshold: 0.18
} }
} }
pg_search_scope :ja_search, pg_search_scope :ja_search,
against: :name_jp, against: %i[name_jp nicknames_jp],
using: { using: {
tsearch: { tsearch: {
prefix: true, prefix: true,

View file

@ -14,15 +14,19 @@ class Summon < ApplicationRecord
} }
pg_search_scope :en_search, pg_search_scope :en_search,
against: :name_en, against: %i[name_en nicknames_en],
using: { using: {
tsearch: {
prefix: true,
dictionary: 'simple'
},
trigram: { trigram: {
threshold: 0.18 threshold: 0.18
} }
} }
pg_search_scope :ja_search, pg_search_scope :ja_search,
against: :name_jp, against: %i[name_jp nicknames_jp],
using: { using: {
tsearch: { tsearch: {
prefix: true, prefix: true,

View file

@ -14,15 +14,19 @@ class Weapon < ApplicationRecord
} }
pg_search_scope :en_search, pg_search_scope :en_search,
against: :name_en, against: %i[name_en nicknames_en],
using: { using: {
tsearch: {
prefix: true,
dictionary: 'simple'
},
trigram: { trigram: {
threshold: 0.18 threshold: 0.18
} }
} }
pg_search_scope :ja_search, pg_search_scope :ja_search,
against: :name_jp, against: %i[name_jp nicknames_jp],
using: { using: {
tsearch: { tsearch: {
prefix: true, prefix: true,

View 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

View 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

View 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

View file

@ -10,7 +10,7 @@
# #
# It's strongly recommended that you check this file into your version control system. # 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 # These are extensions that must be enabled in order to support this database
enable_extension "btree_gin" enable_extension "btree_gin"
enable_extension "pg_trgm" enable_extension "pg_trgm"