这里先吐槽下,为了Flarum支持中文,我不得讲Mariadb换成了MySQL8.0,只为了Flarum支持中午搜索。。。
因为别的方案更废资源,只有换成MySQL才最简单。
一、修改MySQL配置:
# 在 my.cnf 或 my.ini 的 [mysqld] 段添加
ngram_token_size=2
二、重建索引:
-- 删除旧索引(若无则跳过)
ALTER TABLE flarum_posts DROP INDEX content;
ALTER TABLE flarum_discussions DROP INDEX title;
-- 新建支持中文分词的索引
CREATE FULLTEXT INDEX content ON flarum_posts (content) WITH PARSER ngram;
CREATE FULLTEXT INDEX title ON flarum_discussions (title) WITH PARSER ngram;
看,换了MySQL就这么简单。
至于为什么换掉MariaDB?因为mariadb不支持ngram_token,就这么个简单语句,不得不换成mysql,挺二的一件事。
没有回复内容