Flarum Support for Chinese Keyword Search Optimization

21,541 19

Flarum itself is quite unfriendly toward Chinese. As the versions have evolved, it has gradually begun optimizing its support for Chinese, such as supporting Chinese username registration, which is indeed quite useful. However, the latest beta11 version still does not support searching Chinese content. Fortunately, MySQL has supported full-text indexing for Chinese and Japanese since version 5.7.

In addition, Flarum developers have also said that future versions will use the ElasticSearch distributed full-text search engine, because ElasticSearch is better than this method. However, it has still not been implemented. Please note that this method will affect database performance to some extent.

Method

Modify mysql.cnf and add:

INI
[mysqld]
ngram_token_size=2

After making the modification, the FULLTEXT indexes need to be rebuilt:

SQL
ALTER TABLE flarum_posts DROP INDEX content;
CREATE FULLTEXT INDEX content ON `flarum_posts` (`content`) WITH PARSER ngram;

ALTER TABLE flarum_discussions DROP INDEX title;
CREATE FULLTEXT INDEX title ON `flarum_discussions` (`title`) WITH PARSER ngram;

After rebuilding them, clear the cache in the Flarum administration panel, and you will be able to search Chinese content, including article titles and article content.

Search Chinese content

Comments

(19)
  1. Chrome 79 Windows 10

    mysql.cnf在哪里呀?

    1. Chrome 79 Windows 10

      错误 SQL 查询: ALTER TABLE flarum_posts DROP INDEX content MySQL 返回: 文档 #1146 - Table 'fl.flarum_posts' doesn't exist

  2. QAQ
    Chrome 78 Windows 10

    怎么才能中文注册

    1. Chrome 78 Windows 10

      注册时候显示“用户名只能包含字母、数字及横线 (-)” 不能注册 请问怎么设置?

  3. 木头人
    Chrome 96 Windows 7

    只想夸你,解决了我的问题

  4. Edge 101 Windows 10

    感谢,问题解决了~

  5. 78789797
    Edge 103 Windows 10

    成功了 点赞 好评

Leave a comment

© 2026 Carefree. All rights reserved.

Carefree is a personal site about technology and everyday life, documenting web development, backend, and DevOps practices, plus software tools, digital experiences, and thoughts beyond code.