Magento 搜索引擎相关性问题
我们目前有一个拥有大量库存的 Magento 网站,但我们在现场搜索结果的相关性方面遇到了一些问题。我们目前设置为“合并相似文本和全文”,但结果并非我们所期望的。例如,搜索“Lee Child”(作者),会显示三本 Lee Child 书籍,然后显示三本作者为“Lauren Child”的书籍,然后显示其余的 Lee Child 书籍。
因此,本质上我们希望优先考虑全文搜索,并在类似搜索结果之前查看这些结果。我们还希望在缺货产品之前显示库存产品。
我们有一个测试服务器,我读了一篇论坛帖子,其中说目前 magento 会拆分搜索查询并显示至少包含其中一个单词的产品。
我们修改了Mage_CatalogSearch_Model_Mysql4_Fulltext的第342行(针对CE1.4.2):
if ($like) {
$likeCond = '(' . join(' OR ', $like) . ')';
}
并将“OR”更改为“AND”`
路径:app/code/core/Mage/CatalogSearch/Model/Mysql4/Fulltext.php
这是对早期版本的修复,我们当前运行的是 1.5.0.1。
我是否缺少一些东西来修改 Magento 搜索结果的相关性,或者您能否在代码中为我指出正确的方向?
We currently have a Magento website with a large inventory, we are having some issues with relevance of ON SITE search results. We are currently set to 'combine like and fulltext' but the results are aren't what we expected. For example searching for 'Lee Child' (the author), brings up three Lee Child books, then three books with author as 'Lauren Child' and then the rest of the Lee Child books.
So essentially we want to give preference to the full text search and view those results BEFORE the like search results. We also want to display in stock products before out of stock products.
We have a test server and I read a forum post that said at the moment magento splits the search query and show products which have at least one of the words.
We modified line 342 (for CE1.4.2) of the Mage_CatalogSearch_Model_Mysql4_Fulltext:
if ($like) {
$likeCond = '(' . join(' OR ', $like) . ')';
}
and change “OR” with “AND”`
Path: app/code/core/Mage/CatalogSearch/Model/Mysql4/Fulltext.php
This is a fix for an earlier edition and we are currently running 1.5.0.1.
Is there something I'm missing to tinker with the Magento search results relevance or can you point me in the right direction in the code?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
要进行 AND 搜索而不是 OR,您将需要重写类
方法
中要切换部分的
,
确保之后重新索引搜索索引才能生效。
To make an AND search instead of OR, you will need to rewrite the class
In the method
you want to switch the part
to
Be sure to reindex the search index afterwards to have an effect.
我相信缺少的“钥匙”是以下两项:
您应该能够通过几种不同的方式来完成此操作......在任何一种情况下,您都需要制作上述文件的本地副本。
1) 如果您还没有,请添加“catalogsearch.xml”的本地副本
注意:
由于 Magento 布局“级联”工作,因此最好首先检查任何可用的“其他”Magento 布局目录(“基本”除外)。例如,在我的例子中,我们使用 EE,因此我们首先检查“企业”布局目录以复制文件,然后再查看“基本”目录。
“catalogsearch.xml”的常见位置:
/app/design/frontend/base/default/layout/catalogsearch.xml(作为最后的手段)
/app/design/frontend/enterprise/default/layout/catalogsearch.xml(适用于 EE)
注意:PE也可能有不同的位置...我不是100%。
2) 在“catalogsearch.xml”的“catalogsearch_result_index”部分中添加以下内容:
例如:
引用“search_result_list”句柄(即企业布局):
因此它最终看起来类似于:
或者您可以直接将其放置在“ search_result_list' 块(即基本布局):
3) 确保转储 Magento 缓存/存储并重新索引。
另一种选择是将它们作为“隐藏”表单元素放置在“form.mini.phtml”中
1) 将以下内容放置在“form.mini.phtml”表单中:
现在,将表单的开头放置在“form.mini.phtml”中。 mini.phtml' 看起来类似于:
2) 在 'catalogsearch.xml' 的 'default' 部分('header' 引用句柄)中更改到 'form.mini.phtml' 模板的路径:
3) 确保转储 Magento 缓存/存储并重新索引。
最后说明...
下面是我们设置的“自定义模板”路径结构。位于“企业”目录中,因此我的自定义文件将位于:
/app/design/frontend/enterprise/custom_template/layout/catalogsearch.xml
/app/design/frontend/enterprise/custom_template/template/catalogsearch/form.mini.phtml
希望这是有意义的并且有帮助。
I believe the missing "keys" are the following two items:
You should be able to acomplish this a couple different ways... in either case you'll need to make local copies of the said files.
1) If you don't already have one, add a local copy of 'catalogsearch.xml'
Note:
Since Magento layouts work "cascading" it's a good idea to first check any "other" Magento layout directories available (other than the 'base'). For example, in my case we use EE, so we check the 'enterprise' layout directory first to copy files before looking in the 'base' directory.
Common locations of 'catalogsearch.xml':
/app/design/frontend/base/default/layout/catalogsearch.xml (as last resort)
/app/design/frontend/enterprise/default/layout/catalogsearch.xml (for EE)
Note: There may be a different location with PE as well... I'm not 100%.
2) Add the following within the 'catalogsearch_result_index' section in 'catalogsearch.xml':
For example:
Referencing the 'search_result_list' handle (ie enterprise layout):
So it would end up looking similar to:
Or you can place directly within the 'search_result_list' block (ie base layout):
3) Make sure to dump the Magento cache/storage and reindex.
The other option would be to place them as 'hidden' form elements in 'form.mini.phtml'
1) Place the following within the form in 'form.mini.phtml':
Now, the beginning of the form in 'form.mini.phtml' would look similar to:
2) Change the path to 'form.mini.phtml' template within the 'default' section ('header' reference handle) in 'catalogsearch.xml':
3) Make sure to dump the Magento cache/storage and reindex.
Final note...
Below is the "custom template" path structure we have it setup as. Located in the 'enterprise' directory, so my custom files would be located:
/app/design/frontend/enterprise/custom_template/layout/catalogsearch.xml
/app/design/frontend/enterprise/custom_template/template/catalogsearch/form.mini.phtml
Hope this makes sense and helps.