MySql全文搜索,包含多个包含/以单词开头/以单词结尾或部分匹配单词
每个人 我正在使用MySQL数据库,并且面临全文搜索的问题。我把桌子换成了MyISAM 这是我的问题MySql全文搜索,包含多个包含/以单词开头/以单词结尾或部分匹配单词,mysql,search,full-text-search,Mysql,Search,Full Text Search,每个人 我正在使用MySQL数据库,并且面临全文搜索的问题。我把桌子换成了MyISAM 这是我的问题 $inputwords=" balu text ama som" (// input words by user in a single input box) $result=SELECT * FROM my table Where MATCH (data, remark, purpose) AGAINST ('$inputwords' IN BOOLEAN MODE); 它为所有行提供与任何
$inputwords=" balu text ama som" (// input words by user in a single input box)
$result=SELECT * FROM my table Where MATCH (data, remark, purpose) AGAINST ('$inputwords' IN BOOLEAN MODE);
它为所有行提供与任何输入字的精确匹配
任何帮助…请。要获得
LIKE
行为的全文匹配()
,您必须使用*
,这相当于使用%
作为LIKE。这样做的目的是让整个字符串如下所示:
$inputWords = "*balu* *text* *ama* *som*";
代码如下:
$inputWords = "balu text ama som"; // input words by user in a single input box
// Create array of words by splitting with space char
$keywords = explode(" ", $inputWords);
$words = '';
foreach($keywords as $key => $value) {
// concatenate all words following by space, and add * at start and end of the word
$words .= '*'.$value.'*';
// add space only if it is not the last word
if($key < count($keywords) - 1)
$words .= ' ';
}
“巴鲁”一词将与巴鲁克、巴鲁沙、霍特巴鲁相匹配
我不知道它是如何降低性能的,但它仍然比我的服务器中的
类“%word%”
快得多。要获得类行为的全文匹配()
,必须使用*
进行匹配,这相当于使用%
进行匹配。这样做的目的是让整个字符串如下所示:
$inputWords = "*balu* *text* *ama* *som*";
代码如下:
$inputWords = "balu text ama som"; // input words by user in a single input box
// Create array of words by splitting with space char
$keywords = explode(" ", $inputWords);
$words = '';
foreach($keywords as $key => $value) {
// concatenate all words following by space, and add * at start and end of the word
$words .= '*'.$value.'*';
// add space only if it is not the last word
if($key < count($keywords) - 1)
$words .= ' ';
}
“巴鲁”一词将与巴鲁克、巴鲁沙、霍特巴鲁相匹配
我不知道它是如何降低性能的,但它仍然比我的服务器中的如“%word%”
快得多。*只作为截断运算符工作,因此它是一个“从开始”;它不能执行“以结尾”,所以像“对”(“*text”)这样的匹配不能执行work@lunadir对的但在MyISAM中,自然语言模式下的默认全文搜索将与50%或更多表行中的单词不匹配。因此,要么传递到InnoDB引擎,要么使用布尔模式下的全文作为此回退。是的,我没有注意到MyISAM部分*仅用作截断运算符,因此它是一个“以开始”;它不能执行“以结尾”,所以像“对”(“*text”)这样的匹配不能执行work@lunadir对的但在MyISAM中,自然语言模式下的默认全文搜索将与50%或更多表行中的单词不匹配。因此,要么传递到InnoDB引擎,要么使用布尔模式下的全文作为回退。是的,我没有注意到MyISAM部分