首页 > 代码库 > 快速搜索变高级搜索,快速搜索结果准确率提高
快速搜索变高级搜索,快速搜索结果准确率提高
在MAGENTO的快速搜索中往往得不到好的结果,要嘛是查询不到产品,要嘛是所有产品都列出来,不像高级搜索结果那样理想。 有没有把快速搜索效率提高到高级搜索那个水平呢,可以按下面方法做:
- Do a full DB backup (just in case) (以下操作万一出现问题了,能够还原,最好第一步就是备份数据库及要目录下的APP文件夹。) Replace “OR” with “AND” app/code/core/Mage/CatalogSearch/Model/Resource/Fulltext.php at line 331 and 355. (修改此处文件的这二行, OR 改为 AND,注意大小写)
- model rewrite through our custom module (more preferable)
- placing the app/code/core/Mage/CatalogSearch/Model/Resource/Fulltext.php into app/code/local/Mage/CatalogSearch/Model/Resource/Fulltext.php (faster approach, less preferable) (复制此处文件到这个文件夹)
- Go into database then run: (进入MYSQL数据库,运行以下SQL语句)
UPDATE catalog_eav_attribute SET is_searchable = 0;
This will set all product attributes to “Use in Quick Search” => NO.
- Go into database then run:(进入MYSQL数据库,运行以下SQL语句)
UPDATE catalog_eav_attribute SET is_searchable = 1 WHERE attribute_id = (SELECT attribute_id FROM eav_attribute WHERE attribute_code = "name" AND entity_type_id = (SELECT entity_type_id FROM eav_entity_type WHERE entity_type_code = "catalog_product"));
This will set only the “name” attribute to “Use in Quick Search” => YES, which is sort of the whole point of this article, having one or minimal set of searchable attributes to get more precise result set.
- Go into database then run:(进入MYSQL数据库,运行以下SQL语句,此命令会删除以前建好的搜索条件/search terms,也可以不进行删除)
DELETE FROM catalogsearch_query; DELETE FROM catalogsearch_fulltext;
This will clear all previously built search query.
- Go into Magento admin, then do a full reindex (actually only Catalog Search Index is relevant for this). (重建索行)
You can easily make an extension for switching Magento between its OR and your AND statement, have it exposed as configuration value under System > Configuration > Catalog > Catalog > Catalog Search > OR/AND.(此处可以修改搜索条件为OR还是AND,也就是LIKE/FULLTXT,试试会有不同结果)
Hope this helps.
快速搜索变高级搜索,快速搜索结果准确率提高