wiki pages: change tsvector update trigger to not use test_parser.

Change the wiki_pages tsvector_update_trigger to use
`pg_catalog.english` instead of `public.danbooru`. This changes how wiki
page text is parsed for full-text search to use the standard English
parser instead of test_parser. This is to prepare for dropping
test_parser. Using test_parser here was wrong anyway because it meant
that punctuation wasn't removed from words when indexing wiki pages for
full-text search.
This commit is contained in:
evazion
2021-10-11 02:58:08 -05:00
parent 37a8dc5dbd
commit 7976323f7a
4 changed files with 18 additions and 6 deletions

View File

@@ -194,7 +194,7 @@ module Searchable
end
end
def text_attribute_matches(attribute, value, index_column: nil, ts_config: "english")
def text_attribute_matches(attribute, value, index_column: nil)
return all unless value.present?
column = column_for_attribute(attribute)
@@ -203,9 +203,9 @@ module Searchable
if value =~ /\*/
where("lower(#{qualified_column}) LIKE :value ESCAPE E'\\\\'", value: value.mb_chars.downcase.to_escaped_for_sql_like)
elsif index_column.present?
where("#{table_name}.#{index_column} @@ plainto_tsquery(:ts_config, :value)", ts_config: ts_config, value: value)
where("#{table_name}.#{index_column} @@ plainto_tsquery('english', :value)", value: value)
else
where("to_tsvector(:ts_config, #{qualified_column}) @@ plainto_tsquery(:ts_config, :value)", ts_config: ts_config, value: value)
where("to_tsvector('english', #{qualified_column}) @@ plainto_tsquery('english', :value)", value: value)
end
end