Any indexes to be created when using pg_search_scope for searching within a single model

52 views
Skip to first unread message

Bharat

unread,
Jun 24, 2012, 2:06:08 PM6/24/12
to casecom...@googlegroups.com
Thanks for creating this wonderful gem.  It make leveraging full-text search using Postgres super easy.  It is working great in my application.
I have a doubt though.  All my full-text searches target a single model and are against multi-columns.  Do I have to create any specialized
indexes as Ryan Bates does in his screencast on Postgres full text search?


Here is a specific example:

I have a scenario model which has the following code related to the Postgres full-text search using the pg_search gem:

class Scenario < ActiveRecord::Base
  ...
    include PgSearch
  pg_search_scope :search, :against => [:name, :compute_ngls],
    :using => { :tsearch => {:dictionary => "english"} }


  def self.text_search(query)
    if query.present?
      search(sanitize(query))
    else
      scoped
    end
             end

    ...
end

The call to the text_search method is as follow:

      scenarios = scenarios.text_search(params[:sSearch])
 
I only have regular btree indexes on certain columns, e.g., :name for instance.  I do not have gin or gist indexes.  My question is: should I explicitly create these indexes?  If yes then which kind and on which columns?  Can you please give me the syntax for creating these indexes?

Thanks.

Bharat


Reply all
Reply to author
Forward
0 new messages