Commit b89cee4ae35057247aecbb1c70c25cb3cf1011f7
Exists in
theme-brasil-digital-from-staging
and in
5 other branches
Merge branch 'pg_search_rank' into staging
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 | ... | ... |