简体   繁体   English

MySQL全文搜索不适用于某些单词

[英]MySQL full text search not working on some words

I have made a MySQL full text search with min search length of 3 characters, search is working fine except for some words no results are return where result are available. 我进行了MySQL全文搜索,最小搜索长度为3个字符,搜索正常,但有些单词没有返回结果可用的地方。

If i search for word avg results are returned., If i search for word how no result are returned. 如果我搜索单词avg则返回结果。如果我搜索单词how则不返回结果。

I am trying this way. 我正在尝试这种方式。

$keyword = preg_replace('/  */', ' *', $keyword);
$keyword = preg_replace('/\s+/', ' *', $keyword);
$keyword = preg_replace('/\W+/', ' *', $keyword);
$keyword = "$keyword*";

$query = "SELECT *, MATCH (title, link) AGAINST ( ? IN BOOLEAN MODE) AS rel FROM $table WHERE MATCH (title, link) AGAINST ( ? IN BOOLEAN MODE) GROUP by rel DESC, $order $sort LIMIT $rpp OFFSET $offset";

I tried these solution too but same no result for word `how' 我也尝试过这些解决方案,但“如何”一词同样没有结果

//Changing
$keyword = preg_replace('/  */', ' +', $keyword);
$keyword = preg_replace('/\s+/', ' +', $keyword);
$keyword = preg_replace('/\W+/', ' +', $keyword);

$keyword = preg_replace('/  */', '+', $keyword);
$keyword = preg_replace('/\s+/', '+', $keyword);
$keyword = preg_replace('/\W+/', '+', $keyword);

//In combination
$keyword = "+$keyword*";
$keyword = "$keyword*";    
$keyword = "+$keyword";
$keyword = "$keyword";

Please see and suggest why my search is not working on some words. 请查看并提出为什么我的搜索无法使用某些单词的建议。

Thanks. 谢谢。

Update The word how is present in 10 rows, The word avg is present in 16 rows. 更新单词how出现在10行中,单词avg出现在16行中。 I have more than 650 rows. 我有650多行。 I am using IN BOOLEN MODE in query too so there should be not problem about MySQL 50% rule to make how a stop word . 我也在查询中使用IN BOOLEN MODE ,因此应该没有关于MySQL 50%规则使how停用词的问题。

avg and how are both too short in standard configuration, see documentation . avghow都在标准配置太短,请参阅文档 You changed that, but how is an element of the stop word list : 您对此进行了更改,但是停用词列表中的元素how

Boolean full-text searches have these characteristics: 布尔全文搜索具有以下特征:

The minimum and maximum word length full-text parameters apply. 最小和最大字长全文参数适用。

The stopword list applies. 停用词列表适用。

Override the stopword list with the ft_stopword_file system variable: 使用ft_stopword_file系统变量覆盖停用词列表:

To override the default stopword list, set the ft_stopword_file system variable. 要覆盖默认停用词列表,请设置ft_stopword_file系统变量。 (See Section 5.1.4, “Server System Variables”.) The variable value should be the path name of the file containing the stopword list, or the empty string to disable stopword filtering. (请参见第5.1.4节“服务器系统变量”。)变量值应为包含停用词列表的文件的路径名,或为禁用停用词过滤的空字符串。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM