Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/57.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
MySQL匹配(字段)与('string')对某些人有效,对其他人无效_Mysql - Fatal编程技术网

MySQL匹配(字段)与('string')对某些人有效,对其他人无效

MySQL匹配(字段)与('string')对某些人有效,对其他人无效,mysql,Mysql,我有一个MYSQL表,如下所示: phrase1 phrase2 ssd solid state drive ps 4 playstation 4 短语1和短语2列均为全文 我提出以下质询: select * from phrases where match(phrase1) against('ssd' IN BOOLEAN MODE) OR match(phrase2) against('ssd' IN BOOLEAN MODE); 我回来了: +----+

我有一个MYSQL表,如下所示:

phrase1    phrase2
ssd        solid state drive
ps 4       playstation 4
短语1和短语2列均为全文

我提出以下质询:

select * from phrases
where match(phrase1) against('ssd' IN BOOLEAN MODE)
OR match(phrase2) against('ssd' IN BOOLEAN MODE);
我回来了:

+----+-------------------+---------+
| id | phrase1           | phrase2 |
+----+-------------------+---------+
|  1 | solid state drive | ssd     |
+----+-------------------+---------+
1 row in set (0.00 sec)
但当我发布:

select * from phrases
where match(phrase1) against('ps 4' IN BOOLEAN MODE)
OR match(phrase2) against('ps 4' IN BOOLEAN MODE);
我明白了:

Empty set (0.00 sec)
以下是全文中的一些变量

> show variables like 'ft_%';
+--------------------------+----------------+
| Variable_name            | Value          |
+--------------------------+----------------+
| ft_boolean_syntax        | + -><()~*:""&| |
| ft_max_word_len          | 84             |
| ft_min_word_len          | 1              |
| ft_query_expansion_limit | 20             |
| ft_stopword_file         | (built-in)     |
+--------------------------+----------------+
5 rows in set (0.00 sec)

有什么建议吗?

使用自然语言模式搜索带空格的字符串

因此,您的代码将是:

select * from phrases
where match(phrase1) against('ps 4' IN NATURAL LANGUAGE MODE)
OR match(phrase2) against('ps 4' IN NATURAL LANGUAGE MODE);

让我知道这是否适用于您

空集仍然没有区别。空间不是问题,因为我可以搜索固态驱动器,它可以工作。问题是它不计算1或2个字母单词,即使我将ft_min_word_len设置为1,并通过从各个站点读取重建索引,我可以说只有ft_min_word_len=3是搜索的最小可配置单词限制。只是为了测试,请尝试使用此查询。从短语中选择*,其中布尔模式下matchphrase1对+ps+4,或布尔模式下matchphrase2对+ps+4;试试这个,看看是否有效