简体   繁体   English

在Rails中使用全文本搜索引擎的建议

[英]Advice with Full Text Search Engine in Rails

I am trying to add to my website a search bar like the one on Facebook. 我正在尝试将搜索栏添加到我的网站,例如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 CSS可定制
  • Be able to search through severals table in my PostGreSQL DB. 能够在我的PostGreSQL DB中搜索somes表。
  • I am currently using Heroku for production. 我目前正在使用Heroku进行生产。

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; Heroku对机器配置提供有限的支持; 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 . Heroku通过两种方式提供了这样的选项:1)PostgreSQL具有内置的全文本搜索功能,以及2)Heroku使Flying Sphinx成为了一个选项,以及Heroku网站上记录的这些其他选项 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. 开始打字并开始获取结果无非就是通过AJAX将请求发送到搜索服务器,通常是在短暂的打字延迟(可能是50毫秒)之后,然后处理结果的显示。 There are a couple of ways to make that simple written up here in this SO answer . 有几种方法可以使这个SO答案中的内容变得如此简单。

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 : 我现在暂时保留了PostgreSQL引擎,但是使用select2作为演示文稿的jquery,并且能够获得一个类似于搜索框的facebook:

Select2 with Rails and JSON Select2与Rails和JSON

Thanks for you help ! 谢谢您的帮助!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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