Refactor full-text search to get rid of tsvector columns.
Refactor full-text search on several tables (comments, dmails, forum_posts, forum_topics, notes, and wiki_pages) to use to_tsvector expression indexes instead of dedicated tsvector columns. This way full-text search works the same way across all tables. API changes: * Changed /wiki_pages.json?search[body_matches] to match against only the body. Before `body_matches` matched against both the title and the body. * Added /wiki_pages.json?search[title_or_body_matches] to match against both the title and the body. * Fixed /dmails.json?search[message_matches] to match against both the title and body when doing a wildcard search. Before a wildcard search only matched against the body. * Added /dmails.json?search[body_matches] to match against only the dmail body.
This commit is contained in:
@@ -19,7 +19,7 @@ class Note < ApplicationRecord
|
||||
module SearchMethods
|
||||
def search(params)
|
||||
q = search_attributes(params, :id, :created_at, :updated_at, :is_active, :x, :y, :width, :height, :body, :version, :post)
|
||||
q = q.text_attribute_matches(:body, params[:body_matches], index_column: :body_index)
|
||||
q = q.text_attribute_matches(:body, params[:body_matches])
|
||||
|
||||
q.apply_default_order(params)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user