Rails 3 全文搜索
我正在评估 Rails 3 ATM 的全文搜索方法。这里有人有推荐吗?在我看来,大多数已知方法(Sunspot、Sphinx、Ferret、Xapian)尚未为 Rails 3 做好准备。是这样吗?目前,我的计算机上还剩下大量资源,我想部署我的应用程序,但尽管如此,我还是希望将搜索引擎的空闲负载保持在尽可能低的水平。如果与此相关的话,我计划使用 PostgreSQL。
经过一番阅读后,我几乎确定我想使用 Sunspot 或 Xapian。但如果有任何其他(和更好的)解决方案,请告诉我:-) 特别是关于 Sunspot,我不确定除了我的 Rails 应用程序之外运行一个完整的 Tomcat 是否明智。大家有认识这个星座的经历吗?
提前致谢, 乌尔夫
I’m evaluating full text search methods for Rails 3 ATM. Does anyone here have a recommendation? Seems to me as if most of the known methods (Sunspot, Sphinx, Ferret, Xapian) aren’t yet ready for Rails 3. Is that so? At the moment I’ve got plenty of resources left on the machine were I’d like to deploy my app but nevertheless, I’d like to keep the idle load for the search engine as low as possible. I’m planning to use PostgreSQL if that’s of any relevance here.
After some reading I’m almost sure that I’d like to use Sunspot or Xapian. But if there’s any other (and better) solution please tell me :-) Especially regarding Sunspot I’m not sure if it was clever to have a complete Tomcat running in addition to my Rails app. Anyone has experience with this constellation?
Thanks in advance,
Ulf
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
如果您使用 PostgreSQL,那么在需要访问外部库之前,您可以从其内置文本搜索功能中获得大量信息。我多年来一直使用 tsearch 查询并取得了出色的结果。
PostgreSQL 全文搜索分析单词邻近度来计算相关性&排名并提供有用的功能,例如突出显示搜索结果。
它还知道特定于语言的规范化规则,例如它知道忽略英语中的 s 和 es 复数后缀;因此,搜索“国家/地区”也会返回“国家/地区”的突出显示结果,这与 Google 的做法非常相似。
我并不是建议您不应该使用您提到的库,但值得研究该数据库,看看它是否已经满足您的大部分(如果不是全部)要求。
If you are using PostgreSQL you can get an awful lot out of its built-in text search capabilities before you need to reach for external libraries. I've been using tsearch queries for years with excellent results.
PostgreSQL full text search analyses word proximity to calculate Relevance & ranking and offers useful features like highlighting of search results.
It is also aware of language specific normalisation rules, for example it knows to ignore the s and es pluralization suffixes in English; so searches for 'country' will also bring back highlighted results for 'countries', much the same way that Google does.
I'm not suggesting that you shouldn't use the libraries that you've mentioned, but it is worth investigating the database to see if will already fulfil the majority, if not all of your requirements.
您可以将 sunspot 与 Rails3 一起使用,没问题。我们已经使用 sunspot/sunspot_rails gems (1.2.rc4) 成功地做到了这一点。在 Tomcat 服务器中运行 Solr 也不是太麻烦。
You can use sunspot with Rails3, no problem. We have done so successfully using the sunspot/sunspot_rails gems (1.2.rc4). And it's not too much of a hassle to run Solr within a Tomcat server.
对于全文搜索功能,您应该使用搜索引擎。
例如,您可以将 Lucene 库与 jRuby 一起使用。
如果您喜欢使用标准 Ruby (cRuby),您可以使用 Solr。
对于 Rails,还有一些 Solr 插件:
例如,从 http://wiki.apache.org/solr/SolRuby 开始可能是一个不错的选择主意。
For fulltext-search features you should use a search engine.
For example you could use the Lucene Library with jRuby.
If you like to stay with standard Ruby (cRuby) you coud use Solr.
For rails there are also some Solr plugins:
For example starting with http://wiki.apache.org/solr/SolRuby could be a good idea.
Sunspot 已为 Rails3 做好准备,我们已经在一些 Rails3 应用程序上使用它。我在 Solr 和 Sunspot 方面取得了很大的成功。以至于我们正在开始一个关于它的博客系列
Sunspot is Rails3 ready, we're using it on a few Rails3 apps already. I've had a lot of success with Solr and Sunspot. So much that we're starting a blog series on it