使用 solr 改进搜索结果 +太阳黑子

发布于 2025-01-07 08:55:59 字数 1612 浏览 0 评论 0原文

我想知道是否有什么我可以做的来帮助改善我在 solr 中看到的搜索结果。

我有一个产品模型,其文本字段“名称”的值为“The Glenlivet 18 Year”。

我的产品模型中有此可搜索块:

searchable do
  text :name
end

当我搜索“The Glenlivet Single Malt Scotch 18 Yr. 750ML”时,我得到零结果。

1.9.3-p0 :001 > Product.search { fulltext "The Glenlivet Single Malt Scotch 18 Yr. 750ML"}.results
=> []

看来我必须真正简化搜索查询才能获得结果,这不是很有用。

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
=> []

看起来这个确实应该有用。

1.9.3-p0 :003 > Product.search { fulltext "The Glenlivet 18 Yr."}.results
=> []

最后

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"] 

是 sunspot_solr gem 创建的 solr 中的所有默认设置。这是我的配置文件:

与这些从结果来看,它几乎违背了全文搜索的目的。是否有任何我可以调整的设置或其他任何我可以做的事情,以使这些结果看起来不那么严格?

编辑:

添加 :minimum_match => 4 并设置同义词似乎提供了我想要的结果。

Product.search { fulltext "The Glenlivet Single Malt Scotch 18 Yr. 750ML", :minimum_match => 4}.results 

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 

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

赠意 2025-01-14 08:55:59

确保您的全文字段被视为文本而不是字符串,然后查看最小匹配设置:

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

另外,您可能需要同义词来使年份和年份相等。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文