Question

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?

Was it helpful?

Solution

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:

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top