pg_search
pg_search copied to clipboard
A More Flexible Multisearch
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:
- On the front-end, I want to full-text multisearch records against their content and title.
- 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...
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