sunspot_rails Levenshtein distance operator
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
精彩评论