Function not searching for a specific word
This is quite weird but my search function can search for any word except the word "grinder" from my item table. I have tried every开发者_StackOverflowthing 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 TesterWhen 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 Testerand I search for Grinder, the record => 9 In 15 AMP Motor Angle Grinder is being displayed.
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.
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.
精彩评论