Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

magento search issue

Tags:

search

magento

I have one issue which I am in desperate need for your help. I am on Magento ver. 1.6.1.0, whenever I am searching with a sentence like "baby's cute shoes" in magento then the results are not accurate but when I search only a word like "cute" or "shoes" then it gives me the result.

I have a feeling that magento is not able to search a sentence but it is able to search products with words. Is there anything I can do to better optimize the search in magento?

like image 685
fear_matrix Avatar asked Jan 10 '12 07:01

fear_matrix


4 Answers

The options for search can be found in the backend under System > Catalog > Catalog search, you probably have search type set to LIKE. You will potentially get better results using FULLTEXT mode.

like image 75
Peter O'Callaghan Avatar answered Nov 05 '22 11:11

Peter O'Callaghan


Magento does not search the entered string as a full sentence. Instead it splits (tokenizes) your search string into words and will search for products containing ANY of these words (implementing "OR" logic). So if you are searching for "red shoes", it will find everything containing words "red" OR containing words "shoes". Obviously it is not very useful in most cases as it will produce a lot of totally irrelevant results.

You can check this free extension to refine your search: Catalog Search Refinement FREE. This extension modifies the search behavior to only find the products that have ALL keywords ("AND" logic in other words). This will find only products that have both "red" and "shoes" keywords. There is also Advanced Search version of that extension that also looks up for similar words based on phonetic distance among other things as well as weighted search attributes, allowing to bubble up the most relevant products.

like image 34
obaranovsky Avatar answered Nov 05 '22 09:11

obaranovsky


I got my issue resolved by this link - https://stackoverflow.com/questions/1953715/magento-search-not-returning-expected-results

I went to this line in app/code/core/Mage/CatalogSearch/Model/Resource/Fulltext.php

and did this (below)

copy app/code/core/Mage/CatalogSearch/Model/Mysql4/Fulltext.php to app/code/local/Mage/CatalogSearch/Model/Mysql4/Fulltext.php

line 341 - 343 app/code/local/Mage/CatalogSearch/Model/Mysql4/Fulltext.php

if ($like) { $likeCond = '(' . join(' OR ', $like) . ')'; } change into

if ($like) { $likeCond = '(' . join(' AND ', $like) . ')'; }

like image 2
fear_matrix Avatar answered Nov 05 '22 09:11

fear_matrix


Also make sure to change the order in which the results are shown. Default Magento is to serve it backwards.

Add the following to /app/design/frontend/default/default/layout/catalogsearch.xml

<reference name="search_result_list">
    <action method="setDefaultDirection"><string>asc</string></action>
    <action method="setDefaultOrder"><string>relevance</string></action>
</reference>  

Between the following:

<catalogsearch_result_index translate="label">
   ...
</catalogsearch_result_index>
like image 1
sergeif Avatar answered Nov 05 '22 09:11

sergeif