pg_search: ordering of "multisearchable" results
There is a simple answer but it does not work with "multisearchable".
First, I needed to change from "multisearchable" (which works with multiple models) to "pg_search_scope" (searches in a single model only).
Second, I needed to use :order_within_rank
. Since the results are all 100% matches of the search term, they have the same ranking according to pg_search
. :order_within_rank
gives a secondary rank as a tiebreaker.
class Advert < ActiveRecord::Base
include PgSearch
pg_search_scope :search_by_full_advert,
:against => [:title, :body],
:order_within_rank => "adverts.created_at DESC"
end