diff --git a/plugins/pg_search/lib/ext/active_record.rb b/plugins/pg_search/lib/ext/active_record.rb index 13de478..d47e713 100644 --- a/plugins/pg_search/lib/ext/active_record.rb +++ b/plugins/pg_search/lib/ext/active_record.rb @@ -4,9 +4,8 @@ class ActiveRecord::Base def self.pg_search_plugin_search(query) filtered_query = query.gsub(/[\|\(\)\\\/\s\[\]'"*%&!:]/,' ').split.map{|w| w += ":*"}.join('|') if defined?(self::SEARCHABLE_FIELDS) - select("*,ts_rank(to_tsvector('simple', #{pg_search_plugin_fields}), to_tsquery('#{filtered_query}')) as rank"). - where("to_tsvector('simple', #{pg_search_plugin_fields}) @@ to_tsquery('#{filtered_query}')"). - order("rank DESC") + where("to_tsvector('simple', #{pg_search_plugin_fields}) @@ to_tsquery('#{filtered_query}')"). + order("ts_rank(to_tsvector('simple', #{pg_search_plugin_fields}), to_tsquery('#{filtered_query}')) DESC") else raise "No searchable fields defined for #{self.name}" end -- libgit2 0.21.2