treehollow / treehollow-backend

T大树洞 的Golang后端
https://thuhole.com/
GNU Affero General Public License v3.0
167 stars 47 forks source link

搜索关键词"tag"无法搜到任何内容 #43

Closed thuhole closed 3 years ago

thuhole commented 4 years ago

image

thuhole commented 4 years ago

疑似

FULLTEXT INDEX (text) WITH PARSER ngram

match(text) against(? IN BOOLEAN MODE)

里的MySQL自己的问题?

thuhole commented 4 years ago
mysql> select * from posts where match(text) against ('+tag' in boolean mode);
Empty set (0.00 sec)
yzs981130 commented 4 years ago

feature的label笑死我了

thuhole commented 4 years ago

feature的label笑死我了

这个bug我至今迷惑,不知道你有没有什么想法? 后端是MySQL 8.0,ngram token size是2。P大树洞的搜索应该也是MySQL的Boolean mode搞的,能观察到一些类似的特性,但估计是MySQL 5.x。

yzs981130 commented 4 years ago

feature的label笑死我了

这个bug我至今迷惑,不知道你有没有什么想法? 后端是MySQL 8.0,ngram token size是2。P大树洞的搜索应该也是MySQL的Boolean mode搞的,能观察到一些类似的特性,但估计是MySQL 5.x。

tag是MySQL的boolean下面的关键字吗?我研究研究

thuhole commented 3 years ago

以解决。以root运行以下命令:

CREATE TABLE empty_stopwords(value VARCHAR(30)) ENGINE=INNODB;
set global innodb_ft_server_stopword_table = 'dbname/empty_stopwords';
OPTIMIZE TABLE posts;
thuhole commented 3 years ago

在mysql配置文件中,也需要设置

innodb_ft_server_stopword_table=dbname/empty_stopwords

才可以在mysql重启后确保bug不会重新出现。