Ask A Question

Notifications

You’re not receiving notifications from this thread.

SQL for search

robert asked in General
Hi Chris,

I had a question, solved it, now I'm looking for your feedback. For readability I use `a` in the example below:

a = params[:query]
Item.where("name ILIKE ? OR tagline ILIKE ? OR details ILIKE ?", "%#{a}%", "%#{a}%", "%#{a}%")

Do you have a similar query on gorails search for episode titles and forum thread titles?
Reply
Hey Robert!

I actually use Ransack to take care of this for me, but it's doing basically exactly that. I make two queries when you search, one for episodes, one for forum threads and then just display them in the autocomplete.

Eventually I might switch to ElasticSearch, but it requires a lot of RAM and probably wouldn't be a huge improvement to the search results anyways. 
Reply
ransack is great!  

Reply
Join the discussion
Create an account Log in

Want to stay up-to-date with Ruby on Rails?

Join 87,265+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.