You are here:  » Search troubles

Support Forum



Search troubles

Submitted by pat on Fri, 2007-08-03 05:41 in

Hi David

Could you please have a look at my site:

eurosauna.com

and try to search: hot tub or Hot Tub, Portable Spa or portable spa, etc.

There are many words which are on the pages (title or/and description) and the script brings up results only once in a very little while, searching for "sauna" is ok but "saunas" is not.

I have no idea what to do...

In search.php I have the search name+description setup and this modif

if (0)
{

$words = explode(" ",$parts[0]);
$newWords = array();
foreach($words as $word)
{
if (substr($word,-1)=="s")
{
$newWords[] = substr($word,0,-1);
}
}
$allWords = array_merge($words,$newWords);
$parts[0] = implode($allWords," ");

Which should bring up results instead of nothing

Any idea what I did wrong?

Thanks

Pat

Submitted by support on Fri, 2007-08-03 08:23

Hello Pat,

Because your site has very short, but meaningful words (Tub, Spa etc.), it would not be efficient to use MySQL full text index, which is the default. This will explain why you are not getting any results for many queries, as words less than 4 characters are not indexed by default.

For this site, it will work better if you use the normal search method for all queries. In search.php, look for the following code on line 64:

if (strlen($parts[0]) > 3)

...and change this to:

if (0)

This will disable the full text index. However, in order to search against the description as well, a further modification is required. Look for the following code starting on line 73:

          $sql = "SELECT * , MIN( price ) AS minPrice, MAX( price ) AS maxPrice, COUNT( id ) AS numMerchants FROM `".$config_databaseTablePrefix."products` WHERE search_name LIKE '%".str_replace(" ","",database_safe($parts[0]))."%' OR description LIKE '%".database_safe($parts[0])."%' GROUP BY name";
          $sqlResultCount = "SELECT COUNT(DISTINCT(name)) as resultcount FROM `".$config_databaseTablePrefix."products` WHERE search_name LIKE '%".str_replace(" ","",database_safe($parts[0]))."%' OR description LIKE '%".database_safe($parts[0])."%'";

If you're not sure where to insert these changes, feel free to email me a copy of your existing search.php and I will make the changes for you. Reply to your reg code or forum registration email is the easiest way to get me...!

Cheers,
David.

Submitted by pat on Fri, 2007-08-03 18:25

David

I emailed my search.php because it's a little bit confusing, so many codes look the same....

Thanks

Pat