tags:

views:

44

answers:

2

This is quite weird but my search function can search for any word except the word "grinder" from my item table. I have tried everything but it does not seem to search for that word. Can anyone help me please?

CREATE FULLTEXT INDEX item_name_other_name_desc_index 
    ON item (name,other_name,description) 

public static function Search($string) 
{    

    $delims = ',.; '; 
        $word = strtok($string,$delims); 
        while($word) 
        { 

           $result['accepted'][] = $word;                    
           $word = strtok($delims); 

        } 

          $string = implode(" ", $result['accepted']); 

    $sql = 'SELECT item_id,name,other_name,description,price,discounted_price, thumbnail_photo,large_photo 
    FROM item 
    WHERE  
    MATCH(name,other_name,description) 
    AGAINST(:string)' ; 
    $parameters = array(':string' => $string); 
    $result['items'] = DB::GetAll($sql,$parameters); 
    return $result; 
} 

The names of the items: 9 In 15 AMP Motor Angle Grinder
8 In Bench Grinder
1/4 In Angle Die Grinder
7 In Angle Grinder
3 In Straight Grinder
Ryobi HP512K cordless drill/driver kit
6-Pack Spray Paint
Non-Contact Voltage Tester

When I change the above to :
9 In 15 AMP Motor Angle Grinder
8 In Bench Grind
1/4 In Angle Die Grind
7 In Angle Grind
3 In Straight Grind
Ryobi HP512K cordless drill/driver kit
6-Pack Spray Paint
Non-Contact Voltage Tester

and I search for Grinder, the record => 9 In 15 AMP Motor Angle Grinder is being displayed.

A: 

Does it make any different if the word Grinder is moved within the text, so "15 AMP Motor Angle Grinder" would be "15 AMP Motor Angle Grinder Test"? I ask this because Grinder is always the last work of the name.

I'm not an expert on full text searching, but this is where I would start.

Darryl Hein
+2  A: 

By default, mysql fulltext search treats a word that occurs in more than 50% or the rows as a stopword ( http://dev.mysql.com/doc/refman/5.1/en/fulltext-natural-language.html ). Try searching in boolean mode ( http://dev.mysql.com/doc/refman/5.1/en/fulltext-boolean.html ), where you don't have 50% threshold.

stereofrog
Thanks a lot for your help!
chupinette