Class: FulltextSearchRedux::Postgres
- Inherits:
-
Object
- Object
- FulltextSearchRedux::Postgres
- Defined in:
- lib/fulltext_search_redux/rdbms/postgres.rb
Class Method Summary collapse
Class Method Details
.compatible_search(query) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/fulltext_search_redux/rdbms/postgres.rb', line 3 def self.compatible_search(query) sanitized_query = ActionController::Base.helpers.sanitize(query) rank = <<-RANK ts_rank(to_tsvector(title), plainto_tsquery('#{sanitized_query}')) RANK sql = <<-SQL to_tsvector('english', title) @@ plainto_tsquery(:q) OR to_tsvector('english', content) @@ plainto_tsquery(:q) SQL ->(obj) { obj.where(sql, q: query).order("#{rank} desc") } end |