简体   繁体   中英

Advice with Full Text Search Engine in Rails

I am trying to add to my website a search bar like the one on Facebook. I want my users to be able to search through my products, my other users ... But I also want the result to be displayed in real time without pressing a button. I am currently looking at several options (thinking-sphinx, ferret, ...) but I am not sure which one to use and that's why I would like to get advices from pros ;)

So my requirement are :

  • Result to be displayed in real-time in a box on the current page.
  • Css Customizable
  • Be able to search through severals table in my PostGreSQL DB.
  • I am currently using Heroku for production.

I want to choose the best one for my needs and that's why I am asking your opinion. Thanks in advance !

Make sure to separate how you want data displayed (your first two requirements) from how you want it indexed (third) from how you want to deploy.

Let's start backwards. Heroku provides limited support for machine configuration; both options you mention require installation of a service that reads and writes files. Heroku has such an option in two ways: 1) PostgreSQL has a built-in full-text search capability, and 2) Heroku has made Flying Sphinx an option, as well as these other options documented on the Heroku site . The first two options may provide the easiest linkage to your database, but I haven't tried other options, so it's possible they do too. So now you have a search index, deployed.

Real-time "incremental" search is purely a matter of presentation ... and maybe performance. Start typing and you start getting results is nothing more than sending requests via AJAX to the search server, typically after a short delay in typing (maybe 50ms), and handling the display of results. There are a couple of ways to make that simple written up here in this SO answer .

I ended up keeping the PostgreSQL engine for now but used select2 as the jquery for the presentation and was able to get a facebook like search box :

Select2 with Rails and JSON

Thanks for you help !

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM