All threads / SQL for search

Ask A Question

Notifications

You’re not receiving notifications from this thread.

SQL for search

Robert Hopman 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?
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. 
ransack is great!  

Join the discussion

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

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

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

    logo Created with Sketch.

    Ruby on Rails tutorials, guides, and screencasts for web developers learning Ruby, Rails, Javascript, Turbolinks, Stimulus.js, Vue.js, and more. Icons by Icons8

    © 2020 GoRails, LLC. All rights reserved.