pg-search

How to remove ranking of query results


I have the following pg_search scope on my stories.rb model:

  pg_search_scope   :with_text, 
                    :against => :title, 
                    :using => { :tsearch => { :dictionary => "english" }},
                    :associated_against => { :posts => :contents }

I want the query to return the results ignoring any ranking (I care only about the date the story was last updated order DESC). I know that this is an easy question for most of the people who view it, but how do I turn off the rank ordering in pg_search?


Solution

  • I'm the author of pg_search.

    You could do something like this, which uses ActiveRecord::QueryMethods#reorder

    MyModel.with_text("foo").reorder("updated_at DESC")