1
votes

I recently upgraded my magento from 1.4 to 1.6.1 after fixing lots of bugs i still have one issue. When i search on multiple words, the catalog search will return to many results. eg "samsung 2100" it will search everything on Samsung OR 2100.

I have tried editing

-app/code/core/Mage/CatalogSearch/Model/Mysql4/Fulltext.php(did nothing not even after corrupting)

-app/code/local/Mage/CatalogSearch/Model/Mysql4/Fulltext.php(did nothing not even after corrupting)

-app/code/core/Mage/CatalogSearch/Model/Resource/Fulltext.php(did something)

http://www.magentocommerce.com/boards/viewthread/233799/#t360244

2
Might be helpful if you'd show your code that "did something" (Fulltext.php), so we know what you've tried.Jürgen Thelen
line 345...it does not have this option?<br/> prepareTerms($queryText, $query->getMaxQueryWords());user1287768

2 Answers

3
votes

Go to this file :

/app/code/core/Mage/CatalogSearch/Model/Resource/Fulltext.php

in Line 345 Change OR —> AND

Delete the existing search terms. refresh cache....should work like a charm

check it out here.... Dholo.com

try using Multiword search...it returns only the products which have both the terms/

1
votes

One thing I found with Magento's default search is that it could be a bit smarter in "weighting important fields" For us we found that a lot of our search queries included brand names. E.g. 'nike running shoes'. We also found that a lot of search phrases somehow correlated to categories we'd setup. E.g. 'running shoes'

What I did was wrote a chunk of code that will extract brand names and categories from the search query and use those as filters on the product id's that Fulltext.php saves into the results table.

You want to move the above noted php file from

/app/oode/core/Mage/CatalogSearch/Model/Resource/Fulltext.php to /app/code/local/Mage/CatalogSearch/Model/Resource/Fulltext.php

What I've done is put my code adjustment at:

https://gist.github.com/jaseclamp/10083937

In our situation just this little bit of code greatly increased the accuracy of our search results. The code above also did not seem to conflict with anything Magento was doing in terms of synonmys and redirects, etc. Also the following page would say "Search results for 'original search phrase'" even though we'd modified the search phrase during the actual MySQL query to make it more effective. It added a few microseconds to the processing of the search however once the result was cached subsequent searches would be fast.

If you want to see how my code adjusts the MySQL used to insert the search results into the results table just put:

echo "<pre>"; print_r($sql); die; 

Before the "$adapter->query" at the end of the function.