You are here:  » Can I turn off search capitals or none capitals

Support Forum



Can I turn off search capitals or none capitals

Submitted by mally on Fri, 2008-05-09 23:27 in

Hello David

If some one searches the products on my site, for example they enter look Magazine there are no results, even though I have the following product LOOK Magazine

It doesn't seem to pick it up because of capitals. Is there a way to get the search to pick it up capitals or not?

Cheers

Mally

Submitted by support on Sat, 2008-05-10 07:51

Hi Mally,

Here's the problem - "look" is a default "stop word" for MySQL's full text indexing mechanism, which means that it is not indexed because it is considered to be a common word...

http://dev.mysql.com/doc/refman/5.0/en/fulltext-stopwords.html

I think the best way to handle this (as opposed to re-compiling MySQL to change the stop-word list!) is to have a check for any stop-words that are likely to appear in a magazine title and force the normal search method for those queries.

The original search.php contains this code to check that each word is greater than 3 characters before using the full text index. If you're running an earlier version and can't find this code, email me your latest search.php and i'll update this section together with this fix for you:

        $useFullText = TRUE;
        $words = explode(" ",$parts[0]);
        foreach($words as $word)
        {
          if (strlen($word) <= 3)
          {
            $useFullText = FALSE;
            break;
          }
        }

...and change this as follows:

        $useFullText = TRUE;
        $stopWords = array("look"=>1);
        $words = explode(" ",$parts[0]);
        foreach($words as $word)
        {
          if (strlen($word) <= 3 || $stopWords[strtolower($word)])
          {
            $useFullText = FALSE;
            break;
          }
        }

That should do the trick...

Cheers,
David.