Domanda

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?

È stato utile?

Soluzione

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")
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top