I'm wondering if there was anything I could do help improve a search result I'm seeing with solr.
I have a Product model with a text field "name" with the value "The Glenlivet 18 year".
I have this searchable block in my Product model:
searchable do
text :name
end
When I search for "The Glenlivet Single Malt Scotch 18 Yr. 750ML", I get zero results.
1.9.3-p0 :001 > Product.search { fulltext "The Glenlivet Single Malt Scotch 18 Yr. 750ML"}.results
=> []
It seems like I have to really boil down the search query to get a result, which isn't very useful.
1.9.3-p0 :002 > Product.search { fulltext "The Glenlivet 18 Yr. 750ML"}.results
=> []
1.9.3-p0 :006 > Product.search { fulltext "The Glenlivet Single Malt 18"}.results
=> []
It really seams like this one should work.
1.9.3-p0 :003 > Product.search { fulltext "The Glenlivet 18 Yr."}.results
=> []
Then finally
1.9.3-p0 :007 > Product.search { fulltext "Glenlivet 18"}.results
Product Load (0.2ms) SELECT `products`.* FROM `products` WHERE `products`.`id` IN (8)
=> [#<Product id: 8, name: "The Glenlivet 18 year"]
It's all the default settings in solr that the sunspot_solr gem creates. Here are my config files:
With these kind of results it pretty much defeats the purpose of full text search. Are there any settings I can tweak or anything else I can do so that these results don't seem as strict?
Edit:
Adding the :minimum_match => 4
and setting the synonyms seems to provide the results I want.
Product.search { fulltext "The Glenlivet Single Malt Scotch 18 Yr. 750ML", :minimum_match => 4}.results
schema.xml
? – javanna