sunspot_rails 编辑距离算子
我正在使用 sunspot_rails (在 Rails3 上)将我的 Rails 应用程序连接到 solr 服务器。我真的很想使用 ~ 运算符执行模糊搜索。无论如何,这似乎是不支持的。我现在重新使用 EdgeNGrams,但我对结果并不完全满意。
有什么建议吗?有人能够通过 sunspot_rails 进行 Levenshtein 距离搜索吗?
已解决
adjust_solr_params 方法Sunspot 提供的允许您覆盖默认的查询解析器,以便您可以使用支持 ~.基本上,我让 Sunspot 使用 lucene 查询解析器设置 defType 参数:
Post.search 做 adjustment_solr_params 执行 |params| params[:q] = '字段名称:foo~' params[:defType] = 'lucene' 结尾 结尾
I'm using sunspot_rails (on rails3) to interface my rails app to a solr server. I would really like to perform fuzzy searches using the ~ operator. Anyway it seems that this is not supported. I'm now falling back to use EdgeNGrams but I'm not completely satisfied by the results.
Any suggestion? Is anyone been able to make Levenshtein distance searches through sunspot_rails?
SOLVED
The adjust_solr_params method provided by Sunspot allow you to override the default query parser so you can use one that supports ~. Basically, I made Sunspot use the lucene query parser setting the defType pameter:
Post.search do adjust_solr_params do |params| params[:q] = 'field_name:foo~' params[:defType] = 'lucene' end end
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论