As seen here: https://www.postgresql.org/docs/current/textsearch-controls.html
class Post < ApplicationRecord
pg_search_scope :search_by_title, against: :title
end
Post.search_by_title("word|word")
Post.search_by_title.phrase("somebody once told me the world was gonna roll me")
Post.search_by_title.plain("Shrek is the best")
|
def tsquery_for_term(unsanitized_term) |
|
if options[:negation] && unsanitized_term.start_with?("!") |
|
unsanitized_term[0] = "" |
|
negated = true |
|
end |
|
|
|
sanitized_term = unsanitized_term.gsub(DISALLOWED_TSQUERY_CHARACTERS, " ") |
|
|
|
term_sql = Arel.sql(normalize(connection.quote(sanitized_term))) |
|
|
|
tsquery = tsquery_expression(term_sql, negated: negated, prefix: options[:prefix]) |
|
|
|
Arel::Nodes::NamedFunction.new("to_tsquery", [dictionary, tsquery]).to_sql |
Maybe we can add an options hash here to swap out the desired function? I'm new to Ruby but this is my best guess.
As seen here: https://www.postgresql.org/docs/current/textsearch-controls.html
pg_search/lib/pg_search/features/tsearch.rb
Lines 101 to 113 in 056bddb
Maybe we can add an options hash here to swap out the desired function? I'm new to Ruby but this is my best guess.