有什么理由不在 Heroku 上使用 PostgreSQL 的内置全文搜索? [英] Any reason not use PostgreSQL's built-in full text search on Heroku?

查看:25
本文介绍了有什么理由不在 Heroku 上使用 PostgreSQL 的内置全文搜索?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正准备在 Heroku 上部署一个需要全文搜索的 Rails 应用程序.到目前为止,我一直在使用 MySQL 和 Sphinx 的 VPS 上运行它.

I'm preparing to deploy a Rails app on Heroku that requires full text search. Up to now I've been running it on a VPS using MySQL with Sphinx.

但是,如果我想在 Heroku 上使用 Sphinx 或 Solr,我需要为附加组件付费.

However, if I want to use Sphinx or Solr on Heroku, I'd need to pay for an add-on.

我注意到 PostgreSQL(Heroku 上使用的数据库)具有内置的全文搜索功能.

I notice that PostgreSQL (the DB used on Heroku) has built-in full text search capability.

我不能使用 Postgres 的全文搜索有什么原因吗?它比 Sphinx 慢还是有其他一些主要限制?

Is there a reason I couldn't use Postgres's full-text search? Is it slower than Sphinx or is there some other major limitation?

推荐答案

Edit, 2016 — 为什么不是两者兼而有之?

如果您对 Postgres 与 Lucene 感兴趣,为什么不对两者都感兴趣?查看 Postgres 的 ZomboDB 扩展,它集成了 Elasticsearch 作为一流的索引类型.仍然是一个相当早期的项目,但对我来说看起来很有希望.

Edit, 2016 — Why not both?

If you're interested in Postgres vs. Lucene, why not both? Check out the ZomboDB extension for Postgres, which integrates Elasticsearch as a first-class index type. Still a fairly early project but it looks really promising to me.

(技术上在 Heroku 上不可用,但仍然值得一看.)

(Technically not available on Heroku, but still worth looking at.)

披露:我是 WebsolrBonsai Heroku 插件,所以我的观点有点偏向 Lucene.

Disclosure: I'm a cofounder of the Websolr and Bonsai Heroku add-ons, so my perspective is a bit biased toward Lucene.

我对 Postgres 全文搜索的理解是,它对于简单的用例来说非常可靠,但是 Lucene(以及 Solr 和 ElasticSearch)在性能和功能方面都出色的原因有很多.

My read on Postgres full-text search is that it is pretty solid for straightforward use cases, but there are a number of reasons why Lucene (and thus Solr and ElasticSearch) is superior both in terms of performance and functionality.

对于初学者来说,jpountz 为这个问题提供了一个真正出色的技术答案,为什么 Solr 比 Postgres 快这么多? 值得多读几遍才能真正消化.

For starters, jpountz provides a truly excellent technical answer to the question, Why is Solr so much faster than Postgres? It's worth a couple of reads through to really digest.

我还评论了 最近的 RailsCast 剧集 比较 Postgres 全文搜索与 Solr 的相对优缺点.让我在这里回顾一下:

I also commented on a recent RailsCast episode comparing relative advantages and disadvantages of Postgres full-text search versus Solr. Let me recap that here:

  • 重用您已经在运行的现有服务,而不是设置和维护(或支付)其他东西.
  • 远优于极其缓慢的 SQL LIKE 运算符.
  • 保持数据同步的麻烦更少,因为它们都在同一个数据库中 - 无需与某些外部数据服务 API 进行应用级集成.

离开我的头顶,没有特别的顺序......

Off the top of my head, in no particular order…

  • 将索引和搜索负载与常规数据库负载分开扩展.
  • 更灵活的术语分析,​​用于重音规范化、语言词干提取、N-gram、标记删除……其他很酷的功能,如拼写检查、丰富内容"(例如 PDF 和 Word)提取……
  • Solr/Lucene 可以做 Postgres 全文搜索 TODO 列表上的所有事情 很好.
  • 更好更快的术语相关性排名,可在搜索时高效定制.
  • 对于常见术语或复杂查询的搜索性能可能会更快.
  • 可能比 Postgres 更高效的索引性能.
  • 通过将索引与主数据存储分离,更好地容忍数据模型的变化

显然,我认为基于 Lucene 的专用搜索引擎在这里是更好的选择.基本上,您可以将 Lucene 视为搜索专业知识的事实上的开源存储库.

Clearly I think a dedicated search engine based on Lucene is the better option here. Basically, you can think of Lucene as the de facto open source repository of search expertise.

但如果您唯一的其他选择是 LIKE 运算符,那么 Postgres 全文搜索无疑是一个胜利.

But if your only other option is the LIKE operator, then Postgres full-text search is a definite win.

这篇关于有什么理由不在 Heroku 上使用 PostgreSQL 的内置全文搜索?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆