pg_search icon indicating copy to clipboard operation
pg_search copied to clipboard

A More Flexible Multisearch

Open Emerson opened this issue 10 years ago • 1 comments

Howdy,

I'm using and enjoying pg_search on a number of projects, but have recently come across a use case that I'm not sure is supported by the gem. In my application I have an admin backend and a public facing front-end. Both sides of my app need multisearch, but have different requirements.

My specific use case:

  1. On the front-end, I want to full-text multisearch records against their content and title.
  2. On the admin side, I want to multisearch records against just their title.

Are there any workarounds I could use to satisfy these requirements? I really just need a "Multisearch Light" for the admin stuff...

Emerson avatar Jun 11 '14 14:06 Emerson

Do something like this:

if current_user.role == "admin" 
   @results = PgSearch.multisearch(@q).where(:searchable_type => "title")
else
   @results = PgSearch.multisearch(@q).where("searchable_type='title' or searchable_type='content')
end

daande avatar Dec 08 '15 21:12 daande