1
votes

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 
1
Could you post the definition of the fulltext field and its fieldType from your schema.xml?javanna
I added my schema.xml pastebin.com/53ryHT6HAdamB

1 Answers

1
votes

Make sure your fullext field is treated as text and not a string then look at the minimum match setting:

http://wiki.apache.org/solr/DisMaxQParserPlugin#mm_.28Minimum_.27Should.27_Match.29

Also, you might need synonym to equate year and yr.