Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove ranking of query results

Tags:

pg-search

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?

like image 254
chuck w Avatar asked Jan 11 '13 20:01

chuck w


1 Answers

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")
like image 53
Grant Hutchins Avatar answered Nov 06 '22 18:11

Grant Hutchins