全文搜索mysql与3个字母的单词

时间:2022-09-19 19:10:28

I'm trying to find "the zen" string in a field containing "The Zen Circus". I've got a FULLTEXT index.

我想在包含“The Zen Circus”的字段中找到“禅”字符串。我有一个FULLTEXT索引。

select url,name,
,   MATCH(name) AGAINST ( 'zen*' IN BOOLEAN MODE) as A
,   MATCH(name) AGAINST ( '"the zen*"' IN BOOLEAN MODE) as B
,   MATCH(name) AGAINST ('>the* zen' IN BOOLEAN MODE) as C
,   MATCH(name) AGAINST ('thezen*' IN BOOLEAN MODE) as D
,   MATCH(name) AGAINST ('cir*' IN BOOLEAN MODE) as E
,   MATCH(name) AGAINST ('circus*' IN BOOLEAN MODE) as F
from pages where url='thezencircus'

I've got this result:

我有这个结果:

url = thezencircus
name = The Zen Circus
A = 0   (why?)
B = 0   (why?)
C = 0   (why?)
D = 0   (ok)
E = 1   (ok)
F = 1   (ok)

I've also putted ft_min_word_len = 2 in the msyql config file.

我还在msyql配置文件中输入了ft_min_word_len = 2。

Any idea?

2 个解决方案

#1


10  

See this answer MySQL full text search for words with three or less letters

查看此答案MySQL全文搜索三个或更少字母的单词

[mysqld]
ft_min_word_len=3
Then you must restart the server and rebuild your FULLTEXT indexes.

[mysqld] ft_min_word_len = 3然后,您必须重新启动服务器并重建FULLTEXT索引。

Remeber to restart and rebuild indexes.

记得重新启动并重建索引。


Edit
Run show variables like 'ft_%'; to confirm that the word length matches what you set it to.

#2


0  

Kao is right but that didn't help me at all - why? InnoDB table uses a different setting - try updating this one and checking it with:

Kao是对的,但这对我没有帮助 - 为什么? InnoDB表使用不同的设置 - 尝试更新此设置并使用以下命令进行检查:

    show variables like 'innodb_ft_min_token_size';

#1


10  

See this answer MySQL full text search for words with three or less letters

查看此答案MySQL全文搜索三个或更少字母的单词

[mysqld]
ft_min_word_len=3
Then you must restart the server and rebuild your FULLTEXT indexes.

[mysqld] ft_min_word_len = 3然后,您必须重新启动服务器并重建FULLTEXT索引。

Remeber to restart and rebuild indexes.

记得重新启动并重建索引。


Edit
Run show variables like 'ft_%'; to confirm that the word length matches what you set it to.

#2


0  

Kao is right but that didn't help me at all - why? InnoDB table uses a different setting - try updating this one and checking it with:

Kao是对的,但这对我没有帮助 - 为什么? InnoDB表使用不同的设置 - 尝试更新此设置并使用以下命令进行检查:

    show variables like 'innodb_ft_min_token_size';