Matching 2 out of 3 terms in Sunspot and WebSolr

笑着哭i 提交于 2019-12-11 07:57:25

问题


THe partial matching on my search is not working correctly. When I type in "Dublin Ireland" into my search then it correctly returns all the results in Dublin, Ireland. However, when I type "County Dublin Ireland" then it doesn't return any.

I've set up an EdgeNGramFilter in my schmea.xml like so:

<filter class="solr.EdgeNGramFilterFactory" minGramSize="1" maxGramSize="10"/>

And I'm doing a fulltext search on the sunspot end on location:

search_results = Events.solr_search do
  fulltext location do
    fields(:address)
  end
end

How come I'm getting no results even though 2 out of the 3 terms match?


回答1:


By default, Sunspot uses the DisMax Query Parser, and supports a minimum_match method within the fulltext block.

search_results = Events.solr_search do
  fulltext location do
    fields :address
    minimum_match 2
  end
end

See also:

  • Stack Overflow - Solr Sunspot minimum_match
  • Stack Overflow - Rails 3 Sunspot Fulltext Search Usage
  • Solr Wiki - DisMax query parser
  • Websolr Blog - How do I query with boolean logic using Sunspot?


来源:https://stackoverflow.com/questions/12246670/matching-2-out-of-3-terms-in-sunspot-and-websolr

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!