Commit 0bf258185eaf72284e826757b8adf0cf5c062c53
Exists in
theme-brasil-digital-from-staging
and in
4 other branches
Merge branch 'pg_search_rank' into staging_rails4
Showing
1 changed file
with
2 additions
and
3 deletions
Show diff stats
plugins/pg_search/lib/ext/active_record.rb
... | ... | @@ -4,9 +4,8 @@ class ActiveRecord::Base |
4 | 4 | def self.pg_search_plugin_search(query) |
5 | 5 | filtered_query = query.gsub(/[\|\(\)\\\/\s\[\]'"*%&!:]/,' ').split.map{|w| w += ":*"}.join('|') |
6 | 6 | if defined?(self::SEARCHABLE_FIELDS) |
7 | - select("*,ts_rank(to_tsvector('simple', #{pg_search_plugin_fields}), to_tsquery('#{filtered_query}')) as rank"). | |
8 | - where("to_tsvector('simple', #{pg_search_plugin_fields}) @@ to_tsquery('#{filtered_query}')"). | |
9 | - order("rank DESC") | |
7 | + where("to_tsvector('simple', #{pg_search_plugin_fields}) @@ to_tsquery('#{filtered_query}')"). | |
8 | + order("ts_rank(to_tsvector('simple', #{pg_search_plugin_fields}), to_tsquery('#{filtered_query}')) DESC") | |
10 | 9 | else |
11 | 10 | raise "No searchable fields defined for #{self.name}" |
12 | 11 | end | ... | ... |