简体   繁体   English

需要建议:Rails,Postgres和模糊全文搜索

[英]Recommendation needed: Rails, Postgres and fuzzy full text search

I have Rails app with a Postgres backend. 我有一个Postgres后端的Rails应用程序。

I need to add full text search which would allow fuzzy searches based on Levenshtein distance or other similar metrics. 我需要添加全文搜索,这将允许基于Levenshtein距离或其他类似指标的模糊搜索。 Add the fact that the lexer/stemmer has to work with non-English words (it would be ok to just switch language-dependent features off when lexing, to not mess with the target language which may have meaningful words considered by English engine as irrelevant). 添加词法分析器/词干分析器必须使用非英语单词这一事实(可以在lexing时关闭与语言相关的功能,而不是弄乱目标语言,这可能会使英语引擎认为有意义的单词无关紧要)。

I guess Postgres' tsearch won't apply here as it doesn't have fuzzy search -- please correct me if I'm wrong. 我想Postgres的研究不会在这里适用,因为它没有模糊搜索 - 如果我错了,请纠正我。

What are possible combinations of backends & plugins? 后端和插件的可能组合有哪些? It'd like to prefer solutions which add less to the infrastructure (eg. if Postgres can have fuzzy fts, why use external Lucene); 它更喜欢在基础设施上添加较少的解决方案(例如,如果Postgres有模糊fts,为什么要使用外部Lucene); OTOH, the quality of Rails plugins involved is important as well. OTOH,Rails插件的质量也很重要。

What would you recommend? 你会推荐什么?

update : seems like I'd need rather n-gram based metrics than Levenshtein. 更新 :似乎我需要比Levenshtein更基于n-gram的指标。

Rails + Postgres + Solr + Sunspot Rails + Postgres + Solr + Sunspot

Solr is based on Lucene so you can take advantage of all Lucene features. Solr以Lucene为基础,因此您可以充分利用Lucene的所有功能。 Sunspot is an excellent Ruby wrapper for Solr API. Sunspot是Solr API的优秀Ruby包装器。 Both Sunspot and Solr work great with Rails and PostgreSQL, I used it for a project no more than one month ago. Sunspot和Solr都适用于Rails和PostgreSQL,我在一个月之前将它用于一个项目。

PostgreSQL comes with an extension called pg_trgm (in the contrib/ directory). PostgreSQL附带了一个名为pg_trgm的扩展(在contrib /目录中)。 In my experience, it is too slow (more like a proof-of-concept implementation), but for your application it might work. 根据我的经验,它太慢(更像是概念验证实现),但对于您的应用程序,它可能会起作用。

texticle为Postgres提供beta模糊搜索。

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

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