MySQL全文检索
mysql版本 MySQL 5.7.27
public function testKeywords(){ $keywords = request()->param('keywords'); $keywords = fenci($keywords); // 调用百度分词 $keywordsStr = ""; for ($i = 0 ;$i<count($keywords);$i++){ if($i==count($keywords)-1){ $keywordsStr.="$keywords[$i]"; }else{ $keywordsStr.="$keywords[$i] "; } } echo $keywordsStr; $res = \think\Db::query("SELECT * FROM fa_love_chat WHERE MATCH (first_str) AGAINST ('{$keywordsStr}')"); } |
参考
https://www.jianshu.com/p/c48106149b6a/ 注意创建索引的语句
https://www.cnblogs.com/devcjq/articles/6340111.html