Flarum 中文搜索教程

学习 · 2022-12-09 · 1187 人浏览

中文搜索

  1. 数据库配置文件/etc/my.cnf中增加
[mysqld] ngram_token_size=n

分词数可自行修改,n = 几,就是将几个字按照一个词来分组:
n=1: '生', '日', '快', '乐'
n=2: '生日', '日快', '快乐'
n=3: '生日快', '日快乐'
n=4: '生日快乐'
  1. 重建索引
USE Flarum; // 这里替换为你的 Flarum 数据库的名字 
ALTER TABLE posts DROP INDEX content; // 如果你有表前缀,给 posts 加上前缀即可,下面都是如此。 
CREATE FULLTEXT INDEX content ON `posts` (`content`) WITH PARSER ngram; // 注意表前缀
ALTER TABLE discussions DROP INDEX title; // 注意表前缀 
CREATE FULLTEXT INDEX title ON discussions (title) WITH PARSER ngram;
  1. 搜索结果高亮
/* 搜索结果关键字高亮 */
.DiscussionListItem-main mark {
background: #FFE300;
padding: 0px 5px;
margin-right: 2px;
}

常用插件

#中文语言包
composer require flarum-lang/chinese-simplified

#用户创建窗口
composer require clarkwinkelmann/flarum-ext-create-user-modal

#以其他身份登陆
composer require fof/impersonate:"*"

#最佳答案
composer require fof/best-answer:"*"

#LDAP登陆,需要安装php-ldap扩展
composer require tituspijean/flarum-ext-auth-ldap

#上传组件
composer require fof/upload

#链接
composer require fof/links

#页面
composer require fof/pages

#投票
composer update fof/polls

#用户目录
composer require fof/user-directory:"*"

#允许用户裁剪上传的头像
composer require fof/profile-image-crop:"*"

#图片灯箱
composer require darkle/fancybox

#超级置顶
composer require the-turk/flarum-stickiest:^2.0.1

#徽章
composer require v17development/flarum-user-badges

#邮箱美化
composer require fof/pretty-mail

#发帖模板
composer require askvortsov/flarum-discussion-templates
Flarum 中文搜索
Theme Jasmine by Kent Liao