2、mysql数据库对需要搜索的字段增加全文索引。alter table your_table add FULLTEXT KEY name
(name
) with parser ngram; 这里注意,必须要加上 with parser ngram 条件的自然语言模式,否则无法进行中文匹配。另外还有一个坑,mariaDB不支持此参数,故又把数据库从mariaDB切换回mysql8.
$pscws = new PSCWS4('utf8');
$pscws->set_dict('/path/to/etc/dict.xdb');
$pscws->set_rule('/path/to/etc/rules.ini');
$pscws->send_text($text);
while ($some = $pscws->get_result()){
foreach ($some as $word){
array_push($splitWordArr, $word['word'];
}
}
$splitWord = implode(' ', $splitWordArr);
select * from your_table where match(name
) against ($splitWord);